当前位置: 首页 > news >正文

建设网站的五个步骤电脑学校培训

建设网站的五个步骤,电脑学校培训,企业网站管理系统(多语言),做网站公司如何赚钱ToLua是使用原生C#List 介绍Lua中使用原生ListC#调用luaLua中操作打印测试如下 Lua中使用原生DictionaryC#调用luaLua中操作打印测试如下 介绍 当你用ToLua时C#和Lua之间肯定是会互相调用的,那么lua里面使用List和Dictionary肯定是必然的,在C#中可以调用…

ToLua是使用原生C#List

  • 介绍
  • Lua中使用原生List
    • C#调用lua
    • Lua中操作
    • 打印测试如下
  • Lua中使用原生Dictionary
    • C#调用lua
    • Lua中操作
    • 打印测试如下

介绍

当你用ToLua时C#和Lua之间肯定是会互相调用的,那么lua里面使用List和Dictionary肯定是必然的,在C#中可以调用LuaTable、LuaDictTable、LuArrayTable这三种和List、Dictionary进行互相转换和调用,在Lua里面其实也可以将List和Dictionary转换成LuaTable,不转换当然也可以使用。

Lua中使用原生List

这里我会将一些我用到的基础用法列举一下,List< T >自定义的T也是支持的,这里不具体展示了
下面是两个List表传入到Lua中,在lua中操作两个List

C#调用lua

无GC的调用可以参考我无GC调用lua的文章

        List<int> lst = new List<int>();lst.Add(2);lst.Add(3);lst.Add(4);List<int> lst2 = new List<int>();lst2.Add(10);lst2.Add(11);lst2.Add(12);//Util.CallMethod("UIMainCityCtrl", "CSharpListTest", lst, lst2);Util.NoGCCallMethod<List<int>,List<int>>("UIMainCityCtrl", "CSharpListTest", lst, lst2); 

Lua中操作

这里其实已经把List打了Wrap文件,所以List是可以在lua中直接调用如下所示的一些常规操作


function UIMainCityCtrl.CSharpListTest(CSharpList,lst2)CSharpList:Add(555)this.LstLog(CSharpList)logError(tostring(CSharpList:Contains(555)))CSharpList:Remove(555)this.LstLog(CSharpList)CSharpList:AddRange(lst2)this.LstLog(CSharpList)CSharpList:RemoveAt(0)CSharpList:Insert(0, 123)this.LstLog(CSharpList)CSharpList:Clear()this.LstLog(CSharpList)
endfunction this.LstLog(lst)logError("Count = "..lst.Count)for i=0,lst.Count - 1 dologError("lst["..i.."]"..lst[i])end
end

打印测试如下

可以结合我上面的代码部分和操作对比一下下面的打印
在这里插入图片描述

Lua中使用原生Dictionary

C#调用lua

无GC的调用可以参考我无GC调用lua的文章

        Dictionary<int,int> dic1 = new Dictionary<int,int>();dic1.Add(1, 10);dic1.Add(2, 20);Dictionary<int,int> dic2 = new Dictionary<int,int>();dic2.Add(3, 30);dic2.Add(4, 40);//Util.CallMethod("UIMainCityCtrl", "CSharpListTest", lst, lst2);Util.NoGCCallMethod<Dictionary<int, int>, Dictionary<int, int>>("UIMainCityCtrl", "CSharpListTest", dic1, dic2); 

Lua中操作

这里其实已经把List打了Wrap文件,所以List是可以在lua中直接调用如下所示的一些常规操作


function UIMainCityCtrl.CSharpListTest(dic1,dic2)logError("dic1[1] = "..dic1[1])logError("dic1[2] = "..dic1[2])logError("dic2[3] = "..dic2[3])logError("dic2[4] = "..dic2[4])this.LstLog(dic1)this.LstLog(dic2)dic1:Add(3,50)dic1:Add(4,60)this.LstLog(dic1)logError("dic1:ContainsKey()"..tostring(dic1:ContainsKey(1)))logError("dic1:ContainsValue()"..tostring(dic1:ContainsValue(3)))dic1:Clear()this.LstLog(dic1)endfunction this.LstLog(dic)logError("Count = "..dic.Count)local iter = dic:GetEnumerator()while iter:MoveNext() dolocal k = iter.Current.Keylocal v = iter.Current.ValuelogError("k = "..k.." , v = "..v)end
end

打印测试如下

可以结合我上面的代码部分和操作对比一下下面的打印
在这里插入图片描述

http://www.fp688.cn/news/1258.html

相关文章:

  • 自己做的网站怎么让别人看到百度seo优化网站
  • 邢台住房和城乡建设部网站百度关键词排名手机
  • 门厂家网站建设免费培训seo
  • 我是建造网站杭州专业seo
  • 做静态网站哈尔滨网络seo公司
  • 怎样用dw做新闻发布网站苏州百度
  • 广告发布包括哪些湘潭seo快速排名
  • wordpress单页视差南宁seo公司
  • 云南昆明网站建设知乎推广公司
  • 免费域名申请网站大全推荐seo排名推广工具
  • 江西app网站建设网站建设的基本流程
  • 做古玩生意哪些网站好网络营销成功案例
  • 域名注册是什么意思阳城seo排名
  • asp动态网站设计模板专业培训
  • 启源网站建设网络营销的类型有哪些
  • 合肥做网站的企业百度推广自己怎么做
  • 松江品划做企业网站手游推广渠道平台
  • ppt免费下载模板网站济南seo排名优化推广
  • 深圳市工商注册信息查询网站郑州做网站公司排名
  • 游戏抽奖网站用java怎么做的竞价推广遇到恶意点击怎么办
  • 企业网站域名后缀软文时光发稿平台
  • 简述电子商务网站的建站流程长沙网络公司营销推广
  • 政府网站建设由哪个部门负责百度直播
  • wordpress调用评论数seo优化网站源码
  • 微信小程序工具类排行阿拉善盟seo
  • 深圳趣网站建设搜索引擎优化网站的网址
  • 广州广告网站建设太原网站建设谁家好
  • 网站建设工期安排表找网站公司制作网站
  • 高端网站建设公司兴田德润在那里杭州seo技术
  • 广州网站建设 企业电子商务营销模式有哪些