Domanda

i have a Dictionary. it is most important that this dictionary will use its Containskey() method as not case sensitive that is why i use the constructor to make it case insensitive:

 Dictionary<string, string> wishProductNames = new Dictionary<string, string>(StringComparer.CurrentCultureIgnoreCase);
            DBService.GetNameAndPhrases(ref wishProductNames);

i send it to a WCF service Method to be filled and return. it works ok but the case sensitive property is reset back to being case sensitive, and i can't set it back because it is only set in creation.

i can always use arrays to get the data from the WCF and then fill the Dictionary and i can always copy the result dictionary to another which is case insensitive , but how do i overcome the property reset issue ?

È stato utile?

Soluzione

You can't. The comparer associated with the dictionary is not part of the data serialization and deserialization.

You can however easily recreate a dictionary with the same items and the appropriate comparer through the Dictionary(IDictionary dictionary, IEqualityComparer comparer) constructor overload.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top