"命名空间不能直接包含成员如字段或方法"在Net.Reflector [英] "A namespace cannot directly contain members such as fields or methods" in Net.Reflector

查看:1993
本文介绍了"命名空间不能直接包含成员如字段或方法"在Net.Reflector的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用这个code为NET.reflector。使用Reflexil,我试图取代code本,

I am trying to use this code for NET.reflector. Using Reflexil, I am trying to replace code with this,

if(Input.GetKeyDown(KeyCode.Keypad5)) { 
int i = 0; 
Character localPlayer = PlayerClient.GetLocalPlayer().controllable.GetComponent<Character>(); 
foreach (UnityEngine.Object obj2 in UnityEngine.Object.FindObjectsOfType(typeof(LootableObject))) 
{ 
    if (obj2 != null) 
    { 
        i++; 
        LootableObject loot = (LootableObject) obj2; 
        Debug.Log("Loot "+i+": "+loot.transform.position.ToString()); 
        CCMotor ccmotor = localPlayer.ccmotor; 
        if(ccmotor != null && tpPos1 != Vector3.zero) { 
            ccmotor.Teleport(loot.transform.position); 
            Notice.Popup("", "Teleported to "+loot.name, 1.5f); 
        } 
        break; 
    } 
} 

}

但它给了我一个错误,当我尝试编译:

But it gives me an error when I try to compile:

Line: 1 Column: 1 Error Number: CS0116  Error Message: "A namespace does not directly contain members such as fields or methods"

这是团结code,我认为。我不是有经验的。谁能解决这个问题给我吗?或者告诉我该怎么做?谢谢你。

This is Unity code I think. I am not that experienced. Could anyone fix this for me? Or tell me what to do? Thanks.

推荐答案

你展示似乎并没有为错误直接负责的片断。

The snippet you're showing doesn't seem to be directly responsible for the error.

这是你如何会导致错误:

This is how you can CAUSE the error:

namespace MyNameSpace
{
   int i; <-- THIS NEEDS TO BE INSIDE THE CLASS

   class MyClass
   {
      ...
   }
}

如果您没有立即看到什么是外之类,这可能是由于错位或额外的右括号(S)}

If you don't immediately see what is "outside" the class, this may be due to misplaced or extra closing bracket(s) }.

这篇关于&QUOT;命名空间不能直接包含成员如字段或方法&QUOT;在Net.Reflector的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆