好的,这是我的代码它不起作用,即使我从书中复制了一个代码并应用了许多限制throw get和set属性但没有任何工作.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
private string name;
public string Name
{
get
{
return name;
}
set
{
if (string.IsNullOrEmpty(value))
throw new ArgumentNullException("value");
name = value;
}
}
static void Main(string[] args)
{
Program p = new Program();
p.name = null;
Console.WriteLine("{0}", p.name);
Console.ReadLine();
}
}
}**
Run Code Online (Sandbox Code Playgroud)
空字符串仍然存在,并且完全没有例外.难道我做错了什么.
在c中,抽象方法必须由子类实现.所以我的问题是当接口继承另一个接口时为什么它不实现所有基接口成员.
public interface IShape
{
void Points();
}
public interface ICircle: IShape
{
void IsDrawAble();
}
Run Code Online (Sandbox Code Playgroud)
当我在Visual Studio 2010中运行此程序时,没有出现任何错误.根据定义,ICircle必须实现Points函数.
谢谢