using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace Testlnterface4
{
interface MyWord
{ void Paint();
string Word
{ get;
set;
}
}
class Program:MyWord
{
public void Paint()
{ Console.WriteLine("Word");
}
public string Word
{ get { return Word; }
set { Word = value; }
}
string word = "Hello C# 3.0"; static void Main(string[] args)
{
}
}
}请问像上面这段代码,怎么才能输入: Console.WriteLine("Word"); 和 ring word = "Hello C# 3.0";呢?
我实例化Program后调用Panit方法系统提示不能转换成void。
请高手教下我怎么才能输出,谢谢
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace Testlnterface4
{
interface MyWord
{ void Paint();
string Word
{ get;
set;
}
}
class Program:MyWord
{
public void Paint()
{ Console.WriteLine("Word");
}
public string Word
{ get { return Word; }
set { Word = value; }
}
string word = "Hello C# 3.0"; static void Main(string[] args)
{
}
}
}请问像上面这段代码,怎么才能输入: Console.WriteLine("Word"); 和 ring word = "Hello C# 3.0";呢?
我实例化Program后调用Panit方法系统提示不能转换成void。
请高手教下我怎么才能输出,谢谢
{
Console.WriteLine("Word");
}
{ get { return word; }
set { word = value; }
}
static void Main(string[] args)
{
Program p = new Program();
p.Paint();
Console.WriteLine(p.Word);
Console.ReadKey();
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace Testlnterface4
{
interface IMyWord//接口定义前加一般最好+“I”
{ void Paint();
//接口一般不要定义属性
}
class MyWord:IMyWord
{
public void Paint()
{ Console.WriteLine(Word);
}
public string Word
{
get { return Word; }
set { Word = value; }
}
string word = "Hello C# 3.0"; class program
{
static void Main(string[] args)
{
IMyWord mw = new MyWord();//实例化实现接口的类
mw.Paint();
}
}
}
谢谢,可以了啊。
原来这个Word和word是有区别的啊。
呵呵。