Difference between Serializable and MarshalByRefObject

后端 未结 2 1449
春和景丽
春和景丽 2021-02-06 15:28

I am very confused with [Serializable] and :MarshalByRefObject attribute in .NET Remoting .However i read many article on that

2条回答
  •  悲哀的现实
    2021-02-06 16:09

    Adding to @edokan answer, Serializable attribute basically marks a type as being meant to be serialized (i.e, converted to a byte stream).

    Frameworks (such as ORM mappers, oodbs, persistence engines) may use this information to take decisions such as whenever the state of objects should be persisted in databases, sent over a network, etc.

    You can use classes such BinaryFormatter to take an object marked with the Serializable attribute and create byte stream from it and store it in a file and/or send it over network and latter, reconstruct your object again from these streams.

提交回复
热议问题