小编Sha*_*hah的帖子

在c sharp中获取和设置属性不起作用

好的,这是我的代码它不起作用,即使我从书中复制了一个代码并应用了许多限制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# c#-4.0

1
推荐指数
1
解决办法
9989
查看次数

C#中的继承接口

在c中,抽象方法必须由子类实现.所以我的问题是当接口继承另一个接口时为什么它不实现所有基接口成员.

public interface IShape
{
  void Points();
}
public interface ICircle: IShape
{
  void IsDrawAble();
}
Run Code Online (Sandbox Code Playgroud)

当我在Visual Studio 2010中运行此程序时,没有出现任何错误.根据定义,ICircle必须实现Points函数.

谢谢

c# inheritance interface

0
推荐指数
1
解决办法
393
查看次数

标签 统计

c# ×2

c#-4.0 ×1

inheritance ×1

interface ×1