C#字典和列表转LuaTable

2023-12-24 05:42:54

将C#Dictionary转成luaTable

function DicToLuaTable(Dic)
    --将C#的Dic转成Lua的Table
    local dic = {}
    if Dic then
        local iter = Dic:GetEnumerator()
        while iter:MoveNext() do
            local k = iter.Current.Key
            local v = iter.Current.Value
            dic[k] = v
        end
    end
    return dic
end

将C#List转成luaTable

function ListToTable(List)
    --将C#的List转成Lua的Table
    local list = {}
    if List then
        local index = 1
        local iter = List:GetEnumerator()
        while iter:MoveNext() do
            local v = iter.Current
            list[index] = v
            index = index + 1
        end
    else
        logError("Error,CSharpList is null")
    end
    return list
end

文章来源:https://blog.csdn.net/qq_42194657/article/details/135170837
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。