Why Dictionary is serializable ?
Does anyone know the reason why Dictionary is serializable ?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Niradhip ChakrabortyPosted Sep 5, 2009, 3:56 AM
So if you need a keyed list and your objects include unique values, you can use KeyedCollection and get the benefits of serialization as well.
You also can check it out:
1.http://www.c-sharpcorner.com/Blogs/BlogDetail.aspx?BlogId=362
Master BillaPosted Sep 4, 2009, 11:42 PM
When you are look .net class lib for the dictonarty, it inherited from some basic object. take look the snap shot
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
namespace System.Collections.Generic
{
// Summary:
// Represents a collection of keys and values.
//
// Type parameters:
// TKey:
// The type of the keys in the dictionary.
//
// TValue:
// The type of the values in the dictionary.
[Serializable]
[ComVisible(false)]
[DebuggerDisplay("Count = {Count}")]
public class Dictionary<TKey, TValue> : IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IDictionary, ICollection, IEnumerable, ISerializable, IDeserializationCallback
{
// Summary:
// Initializes a new instance of the System.Collections.Generic.Dictionary
// class that is empty, has the default initial capacity, and uses the default
// equality comparer for the key type.
public Dictionary();
//
// Summary:
// Initializes a new instance of the System.Collections.Generic.Dictionary
// class that contains elements copied from the specified System.Collections.Generic.IDictionary
// and uses the default equality comparer for the key type.
//
// Parameters:
// dictionary:
// The System.Collections.Generic.IDictionary whose elements are
// copied to the new System.Collections.Generic.Dictionary.
//
// Exceptions:
// System.ArgumentNullException:
// dictionary is null.
//
// System.ArgumentException:
// dictionary contains one or more duplicate keys.
}
}
Thank you
Roei BarPosted Sep 4, 2009, 5:31 PM