F
fh1996
Documents say that "new" class modifier is only used with nested classes.
"new" indicates that the class hides an inherited member of the same name."
public class MyDerivedC : MyBaseC
{
new public void Invoke() {}
}
The only thing I don't understand in the above statement and example is that
it says that "new" only used with nested classes. However the example isn't
nested class; it's an inheritance. An example of nested class should be
something like:
class NestedClass
{
class MyClass
{
public string name;
public int id;
public MyClass ()
{
}
public MyClass (int id, string name)
{
this.id = id;
this.name = name;
}
}
....
}
Am I misunderstanding "nested class" concept in C#? Would someone share his
light on this?
Many thanks!
"new" indicates that the class hides an inherited member of the same name."
public class MyDerivedC : MyBaseC
{
new public void Invoke() {}
}
The only thing I don't understand in the above statement and example is that
it says that "new" only used with nested classes. However the example isn't
nested class; it's an inheritance. An example of nested class should be
something like:
class NestedClass
{
class MyClass
{
public string name;
public int id;
public MyClass ()
{
}
public MyClass (int id, string name)
{
this.id = id;
this.name = name;
}
}
....
}
Am I misunderstanding "nested class" concept in C#? Would someone share his
light on this?
Many thanks!