c# - Why are interfaces not [Serializable]? -


i think adding attribute interface helpful make sure not create classes use interface , forget make them serializable.

this fundamental question, wanted ask experts.

interfaces define contract , not have state of own.

serialization saving , loading state , out of object model.

not point serializing holds no state.


to answer practical question of forcing implementation of interface serializable - why iserializable interface exists.

in .net can declare interface should implement other interfaces:

interface mustbeserializable : iserializable {} 

see more information here.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -