需要帮助将Lua函数转换为C#

时间:2019-11-26 03:19:48

标签: c#

我需要一些帮助,以将Lua函数转换为C#函数。这是我现在所做的:

Lua中的功能

function GetValueList()
    local List = {"value", "value2", "value3", "value4"}

    for a = 1, #List do
        print(List[a])
    end
end

Csharp中的功能:

private static void GetValueList()
{
    string[] List = { "value", "value2", "value3", "value4" };

}

我现在的大问题,我无法在C#中重现代码Lua的循环

1 个答案:

答案 0 :(得分:1)

这可能有帮助。

public static void PrintValues()
{
    var array = new  [] { "value", "value2", "value3", "value4" };
    foreach(var l in array) {
        System.Console.WriteLine(l);
    }
}