主题:求助
using System;
public class Parent
{
public Parent()
{
Console.WriteLine("Parent Constructor");
}
public Parent(string myString)
{
Parentstring = myString;
Console.WriteLine("Parentstring");
}
public void print()
{
Console.WriteLine("I'm a Parent Class .");
}
}
public class child : Parent
{
public child()
: base("From Derived ")
{
Console.WriteLine("child Constructor");
}
public void print()
{
base .print();
Console .WriteLine("I'm a child class");
}
public static void Main()
{
child child = new child();
child.print();
((Parent)child).print();
}
}
警告 1 “child.print()”隐藏了继承的成员“Parent.print()”。如果是有意隐藏,请使用关键字 new。 C:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\lianxi\lianxi\Program.cs 25 17 lianxi
错误 2 当前上下文中不存在名称“Parentstring” C:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\lianxi\lianxi\Program.cs 10 9 lianxi
2个错误要怎么改呀!!!顺便帮忙解释下程序的意思谢谢
public class Parent
{
public Parent()
{
Console.WriteLine("Parent Constructor");
}
public Parent(string myString)
{
Parentstring = myString;
Console.WriteLine("Parentstring");
}
public void print()
{
Console.WriteLine("I'm a Parent Class .");
}
}
public class child : Parent
{
public child()
: base("From Derived ")
{
Console.WriteLine("child Constructor");
}
public void print()
{
base .print();
Console .WriteLine("I'm a child class");
}
public static void Main()
{
child child = new child();
child.print();
((Parent)child).print();
}
}
警告 1 “child.print()”隐藏了继承的成员“Parent.print()”。如果是有意隐藏,请使用关键字 new。 C:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\lianxi\lianxi\Program.cs 25 17 lianxi
错误 2 当前上下文中不存在名称“Parentstring” C:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\lianxi\lianxi\Program.cs 10 9 lianxi
2个错误要怎么改呀!!!顺便帮忙解释下程序的意思谢谢