using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;namespace ConsoleApplication106
{
class Program
{
public interface Other
{
void Action();
}
public interface Sponsor
{
void RestWith(Other oth);
}
public class Mouse : Other
{
private string name;
public Mouse(string name, Sponsor spo)
{
this.name = name;
spo.RestWith(this);
}
public void Action()
{
Console.WriteLine(name + "escaped!");
}
}
public class Master : Other
{
public Master(Sponsor spo)
{
spo.RestWith(this);
}
}
public void Action()
{
Console.WriteLine("master was awakened!");
}
public class Cat : Sponsor
{
private ArrayList others;
public Cat()
{
this.others = new ArrayList();
}
public void RestWith(Other oth)
{
this.others.Add(oth);
}
public void Yell()
{
Console.WriteLine("Cat yelling!");
foreach (Other oth in this.others)
{
oth.Action();
}
}
} class MainClass
{
static void Main(string[] args)
{
Cat cat = new Cat();
Mouse mouse1 = new Mouse(mouse1, cat);
Mouse mouse2 = new Mouse(mouse2, cat);
Master master = new Master(cat);
cat.Yell();
}
}
}
}
错误提示是:Error 1'ConsoleApplication106.Program.Master' 未實作介面成員 'ConsoleApplication106.Program.Other.Action()'
using System.Collections.Generic;
using System.Text;
using System.Collections;namespace ConsoleApplication106
{
class Program
{
public interface Other
{
void Action();
}
public interface Sponsor
{
void RestWith(Other oth);
}
public class Mouse : Other
{
private string name;
public Mouse(string name, Sponsor spo)
{
this.name = name;
spo.RestWith(this);
}
public void Action()
{
Console.WriteLine(name + "escaped!");
}
}
public class Master : Other
{
public Master(Sponsor spo)
{
spo.RestWith(this);
}
}
public void Action()
{
Console.WriteLine("master was awakened!");
}
public class Cat : Sponsor
{
private ArrayList others;
public Cat()
{
this.others = new ArrayList();
}
public void RestWith(Other oth)
{
this.others.Add(oth);
}
public void Yell()
{
Console.WriteLine("Cat yelling!");
foreach (Other oth in this.others)
{
oth.Action();
}
}
} class MainClass
{
static void Main(string[] args)
{
Cat cat = new Cat();
Mouse mouse1 = new Mouse(mouse1, cat);
Mouse mouse2 = new Mouse(mouse2, cat);
Master master = new Master(cat);
cat.Yell();
}
}
}
}
错误提示是:Error 1'ConsoleApplication106.Program.Master' 未實作介面成員 'ConsoleApplication106.Program.Other.Action()'
解决方案 »
- WebBrowser做多标签浏览器 多线程浏览问题
- vs08遇到问题了
- 算法:返回一个数组前N个数中的最大值,最多使用log 2 (n) [2是底数,n是指数] 次递归调用
- .net如何查找图片上的不同色块,就像Photoshot里的魔术棒效果?
- *****请问如何解析XML中的属性的值******
- Excel导入到access
- cli问题,指针的指针,顺带散分了
- ie直接打开是可以,用程序下载下来不能播放?
- 求一段C#代码HELO MEHELO MEHELO MEHELO MEHELO MEHELO MEHELO MEHELO MEHELO ME
- 打印DataGrid表格的问题,水晶报表,还是有更好用的控件?最高分讨论!!!!!
- c#DataTable显示多行数据
- 关于c#调用组件的奇怪的问题
现在实现了 下面Mouse mouse1 = new Mouse(mouse1, cat);
Mouse mouse2 = new Mouse(mouse2, cat);这里提示错误 :最符合的多载方法···有一些无效的引数 引數 '1': 無法從 'ConsoleApplication106.Program.Mouse' 轉換為 'string'
mouse2也是这个错误
using System.Collections.Generic;
using System.Text;
using System.Collections;namespace ConsoleApplication106
{
class Program
{
public interface Other
{
void Action();
}
public interface Sponsor
{
void RestWith(Other oth);
}
public class Mouse : Other
{
private string name;
public Mouse(string name, Sponsor spo)
{
this.name = name;
spo.RestWith(this);
}
public void Action()
{
Console.WriteLine(name + "escaped!");
}
}
public class Master : Other
{
public Master(Sponsor spo)
{
spo.RestWith(this);
}
public void Action()
{
Console.WriteLine("master was awakened!");
}
}
public class Cat : Sponsor
{
private ArrayList others;
public Cat()
{
this.others = new ArrayList();
}
public void RestWith(Other oth)
{
this.others.Add(oth);
}
public void Yell()
{
Console.WriteLine("Cat yelling!");
foreach (Other oth in this.others)
{
oth.Action();
}
}
} class MainClass
{
static void Main(string[] args)
{
Cat cat = new Cat();
Mouse mouse1 = new Mouse(mouse1, cat);
Mouse mouse2 = new Mouse(mouse2, cat);
Master master = new Master(cat);
cat.Yell();
}
}
}
}
using System.Collections.Generic;
using System.Text;
using System.Collections;namespace ConsoleApplication106
{
class Program
{
public interface Other
{
void Action();
}
public interface Sponsor
{
void RestWith(Other oth);
}
public class Mouse : Other
{
private string name;
public Mouse(string name, Sponsor spo)
{
this.name = name;
spo.RestWith(this);
}
public void Action()
{
Console.WriteLine(name + "escaped!");
}
}
public class Master : Other
{
public Master(Sponsor spo)
{
spo.RestWith(this);
}
public void Action()
{
Console.WriteLine("master was awakened!");
}
}
public class Cat : Sponsor
{
private ArrayList others;
public Cat()
{
this.others = new ArrayList();
}
public void RestWith(Other oth)
{
this.others.Add(oth);
}
public void Yell()
{
Console.WriteLine("Cat yelling!");
foreach (Other oth in this.others)
{
oth.Action();
}
}
} class MainClass
{
static void Main(string[] args)
{
Cat cat = new Cat();
Mouse mouse1 = new Mouse(mouse1, cat);
Mouse mouse2 = new Mouse(mouse2, cat);
Master master = new Master(cat);
cat.Yell();
}
}
}
}
1)class MainClass
{
static void Main(string[] args)
{
Cat cat = new Cat();
string mouse1 = "mouse1";
string mouse2 = "mouse2";
Mouse _mouse1 = new Mouse(mouse1, cat);
Mouse _mouse2 = new Mouse(mouse2, cat);
Master master = new Master(cat);
cat.Yell();
}
}//原因自己想2)public void Yell()
{
Console.WriteLine("Cat yelling!");
foreach (Other oth in this.others)
{
oth.Action();
}
Console.ReadLine();//加这句,要不你看不到结果
}