例:
public class MyTest { public const string HI = "Hello"; public void TestMethod() { string filler; filler = this.HI; //Won't work. filler = HI //Works. } }
无论您是否在类中的静态或实例方法中访问常量,这都适用.