Need to add same properties in two different classes

前端 未结 3 818
被撕碎了的回忆
被撕碎了的回忆 2021-01-25 03:48

I have two classes like Class A and Class B. Class A have some properties, methods and Class B have only the properties. But both Classes have the same set of properties.

<
3条回答
  •  离开以前
    2021-01-25 04:21

    You may achieve this by using an Interface and implementing it both in class A and class B. In the interface, define the property that is required in class A and B:

    public interface ICommonProperty
    {
       string MyProperty{ get; set; }
    }
    

提交回复
热议问题