Idov
Idov

Reputation: 5124

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?

Upvotes: 3

Views: 1967

Answers (2)

RossG
RossG

Reputation: 434

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 :)

Upvotes: 2

Marc Gravell
Marc Gravell

Reputation: 1063774

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

Upvotes: 8

Related Questions