C#可变参数的使用
public List<object> call(string func, params object[] list)
{
int top1 = LuaDLL.lua_gettop(LuaState.getInstance.L);
LuaDLL.lua_getglobal(LuaState.getInstance.L, func);
foreach(object o in list)
{
if(o.GetType() == typeof(string))
{
LuaDLL.lua_pushstring(LuaState.getInstance.L, (string)o);
}else if(o.GetType() == typeof(Int64))
{
LuaDLL.lua_pushnumber(LuaState.getInstance.L, (Int64)o);
}else if(o.GetType() == typeof(double))
{
LuaDLL.lua_pushnumber(LuaState.getInstance.L, (double)o);
}
else if (o.GetType() == typeof(bool))
{
LuaDLL.lua_pushboolean(LuaState.getInstance.L, (bool)o);
}
else if (o.GetType() == typeof(Dictionary<object,object>))
{
pushMapParams(LuaState.getInstance.L, (Dictionary<object, object>)o);
}
else
{
LuaDLL.lua_pushlightuserdata(LuaState.getInstance.L,(IntPtr)o);
}
}
。。。。
}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。