using System;
using System.Collections.Generic;
using System.Text;namespace c832
{
public class father
{
public static int a = 5;
} public class son : father
{
new public static int a = 6;
static void Main(string[] args)
{
Console.WriteLine(a);
}
}
}
new有什么用 说是隐藏继承成员 可是没看懂
有没有好一点的例子呢?
using System.Collections.Generic;
using System.Text;namespace c832
{
public class father
{
public static int a = 5;
} public class son : father
{
new public static int a = 6;
static void Main(string[] args)
{
Console.WriteLine(a);
}
}
}
new有什么用 说是隐藏继承成员 可是没看懂
有没有好一点的例子呢?
这样在子类中直接调用a ,即是本类的成员变量a 。
可以通过base.a调用父类的a。