怎么定位别人苹果手机:c#编程中关于Main函数的一个问题
来源:百度文库 编辑:高校问答 时间:2024/05/13 16:03:21
在下面的一代码(c#)中,
using System;
class A{
public int a = 1;
}
class B:A{
new int a;
public B(int b){
this.a = b;
}
public void showA(){
Console.WriteLine("the value of a is {0}",a);
}
/*public static void Main(){
B bb = new B(4);
Console.WriteLine("value of a:" + bb.a);
bb.showA();
}*/
}
class Demo
{
public static void Main()
{
B bb = new B(4);
Console.WriteLine("the value of a now is" + bb.a);
bb.showA();
}
}
Main函数所在的两个位置不同,得到的结果不同,这是为什么啊
using System;
class A{
public int a = 1;
}
class B:A{
new int a;
public B(int b){
this.a = b;
}
public void showA(){
Console.WriteLine("the value of a is {0}",a);
}
/*public static void Main(){
B bb = new B(4);
Console.WriteLine("value of a:" + bb.a);
bb.showA();
}*/
}
class Demo
{
public static void Main()
{
B bb = new B(4);
Console.WriteLine("the value of a now is" + bb.a);
bb.showA();
}
}
Main函数所在的两个位置不同,得到的结果不同,这是为什么啊
上一位置是错误的。