abstract class allmethod //模板
{
public abstract void testA();
public abstract string testB();
public abstract void getkey(string temp);
public void showmethod()
{
testA();
testB();
getkey(testB());
}
}
class imp : allmethod //方法实现
{
public override void testA()
{
Console.WriteLine("如果你是帅就输入a");
} public override string testB()
{
string temp=Console.ReadLine();
return temp;
}
public override void getkey(string test)
{ Console.WriteLine(test);
if (test.Equals("a"))
{
Console.WriteLine("不要脸");
}
else
{
Console.WriteLine("你确实丑");
}
}
class Program
{
static void Main(string[] args)
{
allmethod op = new imp();
op.showmethod();
}
}
问题:
当我输入a时
却依然无法正常打印
跟踪testB()为空
why?
{
public abstract void testA();
public abstract string testB();
public abstract void getkey(string temp);
public void showmethod()
{
testA();
testB();
getkey(testB());
}
}
class imp : allmethod //方法实现
{
public override void testA()
{
Console.WriteLine("如果你是帅就输入a");
} public override string testB()
{
string temp=Console.ReadLine();
return temp;
}
public override void getkey(string test)
{ Console.WriteLine(test);
if (test.Equals("a"))
{
Console.WriteLine("不要脸");
}
else
{
Console.WriteLine("你确实丑");
}
}
class Program
{
static void Main(string[] args)
{
allmethod op = new imp();
op.showmethod();
}
}
问题:
当我输入a时
却依然无法正常打印
跟踪testB()为空
why?
解决方案 »
- 有关findControl()
- 小问MVC模式
- 不懂啊!急急急。。。。。
- C#的Socket
- 求避免死路的算法
- 删除DatagridView 中记录的问题!!!
- 如何从字符串定位到窗体,然后把字符串转换成窗体……
- 大家来讨论一下怎样防止写的程序被反编译程序反编译
- 关于做密码控件和打包的~~~~~~~~,急~~~急~~~~~~~~~~~~~~~~~~
- 我在做水晶报表时候老是出现String reference not set to an instance of a String. Parameter name: s 这类错误?
- 割脉咬舌跪求(C#数据库问题)
- 请问如何用wise打包时,能关联我自己程序生成的文件,即双击我的文件能打开我的程序,还有图标的关联?谢谢!
public void showmethod()
{
testA();
testB(); //此处应该删出
getkey(testB());
}
因为当第一次执行testB()后,可以准确接收
当getkey(testB())是第二次执行testB()时会再次去调用testB()方法
所以需要再次输入
小弟这不入流的问题让各位见笑了