How can I serialize an object that has an interface as a property?

后端 未结 5 1840
天涯浪人
天涯浪人 2021-01-05 01:45

I have 2 interfaces IA and IB.

public interface IA
{
    IB InterfaceB { get; set;  }
}

public interface IB
{
    IA InterfaceA { get; set;  }

    void Set         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-05 02:30

    Assuming you don't want to serialize the interface property, place the following attribute

    [NonSerialized]
    

    on the interface property.

提交回复
热议问题