public void Len(int idx) { var val = stack.get(idx); if (new LuaValue(val).isString()) { var s = new LuaValue(val).toString(); stack.push((long)s.Length); } else if (new LuaValue(val).isLuaTable()) { var t = new LuaValue(val).toLuaTable(); stack.push((long)t.len()); } else { throw new Exception("length error!"); } }