I have an interface with a property:
interface IFoo
{
object Bar { get; }
}
Is there a way to instruct the implementing class, that the return value of Bar has to be a class that is serializable (marked with the SerializableAttribute)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, there is no way to force the return type of a property of an interface to be marked with
SerializableAttribute.You could consider using
ISerializable, though it is not the same of course, and would force the type to implement the interface, rather than just be marked with the attribute.