当前位置:首页 > C#教程 > C#高级

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);

            }

        }

。。。。

}


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!