Lesson8_Lua调用C#_调用二维数组

--调用c#二维数组
local obj=CS.Lesson8()
Lesson8的声明如下
public class Lesson8
{
    public int[,] array = new int[2, 3] { { 1, 2, 3 }, { 3, 2, 1 } };

}

--打印行列
print("行:" .. obj.array:GetLength(0))
print("列:" .. obj.array:GetLength(1))

--获取元素 不能直接用中括号去调用,lua不支持,只能调c#的方法
print(obj.array:GetValue(0,0))
--遍历
for i=0,obj.array:GetLength(0)-1  do
	for j=0,obj.array:GetLength(1)-1 do
		print(obj.array:GetValue(i,j))
	end
end
posted @ 2024-02-29 21:13  波奇型蠢驴  阅读(14)  评论(0)    收藏  举报