ToLua的Example示例学习笔记21_String

2020-05-14  本文已影响0人  凌枫望星月

这个例子演示了在lua中如何使用String。

1」代码

操作代码如下:

    function Test()
        local str = System.String.New('男儿当自强')
        local index = str:IndexOfAny('儿自')
        print('and index is: '..index)
        local buffer = str:ToCharArray()
        print('str type is: '..type(str)..' buffer[0] is ' .. buffer[0])
        local luastr = tolua.tolstring(buffer)
        print('lua string is: '..luastr..' type is: '..type(luastr))
        luastr = tolua.tolstring(str)
        print('lua string is: '..luastr)                    
    end

2」需要了解的部分

上一篇 下一篇

猜你喜欢

热点阅读