Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 如何用set方法重写get方法_Asp.net Mvc_C# 4.0 - Fatal编程技术网

Asp.net mvc 如何用set方法重写get方法

Asp.net mvc 如何用set方法重写get方法,asp.net-mvc,c#-4.0,Asp.net Mvc,C# 4.0,我有一个方法,像这样: public static ISalesPersonManager SalesPersons { get; } public static ISalesPersonManager SalesPersons { get;set; } 但这是在一个dll类中。所以我不能修改这个类 但是我想给这个方法添加一个set方法 所以像这样: public static ISalesPersonManager SalesPersons { get; } public

我有一个方法,像这样:

  public static ISalesPersonManager SalesPersons { get; }
  public static ISalesPersonManager SalesPersons { get;set; }
但这是在一个dll类中。所以我不能修改这个类

但是我想给这个方法添加一个set方法

所以像这样:

  public static ISalesPersonManager SalesPersons { get; }
  public static ISalesPersonManager SalesPersons { get;set; }
但如何做到这一点呢


谢谢

不可能覆盖get only属性来拥有setter。尽管基类的概念只是描述它的孩子“应该做什么”,而不是描述它的孩子“不应该做什么”,但微软就是这样设计的

不可能覆盖get only属性来拥有setter。尽管基类的概念只是描述它的孩子“应该做什么”,而不是描述它的孩子“不应该做什么”,但微软就是这样设计的

您不能覆盖静态成员,您可以对其进行阴影处理,但通常不推荐使用它,因为它会在programoke中导致意外行为。非常感谢。美好的但解决办法是什么呢?如何添加get方法?您不能覆盖静态成员,您可以对其进行阴影处理,但这通常不是首选方法,因为它可能会在programoke中导致意外行为。非常感谢。美好的但解决办法是什么呢?如何添加get方法?