Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the members with values in SerializationInfo

Is there a way to know which members were added to an instance of SerializationInfo in the GetDataObject method of a ISerializable object?

like image 968
Idov Avatar asked Sep 16 '25 11:09

Idov


2 Answers

Yes: foreach

foreach(SerializationEntry entry in info) {...}

You would be forgiven for not noticing this, as it doesn't implement and IEnumerable API, but: foreach does not require that it does :)

See MSDN for what this provides per item: http://msdn.microsoft.com/en-us/library/system.runtime.serialization.serializationentry(v=vs.110).aspx

like image 90
Marc Gravell Avatar answered Sep 19 '25 00:09

Marc Gravell


There doesn't appear to be a "contains" method. There is a GetEnumerator method that you can use to loop through it. But Marc's foreach suggestion is the better one :)

like image 34
RossG Avatar answered Sep 19 '25 01:09

RossG