प्रलेखन का पालन करने का प्रयास किया और मैं इसे काम नहीं कर सकता। कुंजी स्ट्रिंग के साथ एक keyedCollection है।कीड कोलेक्शन स्ट्रिंग केस असंवेदनशील
कुंजीडॉल चयन में स्ट्रिंग कुंजी केस असंवेदनशील कैसे बनाएं?
एक डिक्शनरी पर बस स्ट्रिंग कॉम्पारेर को पार कर सकता है। ऑर्डिनल इग्नोरकेस सीटीआर में।
private static WordDefKeyed wordDefKeyed = new WordDefKeyed(StringComparer.OrdinalIgnoreCase); // this fails
public class WordDefKeyed : KeyedCollection<string, WordDef>
{
// The parameterless constructor of the base class creates a
// KeyedCollection with an internal dictionary. For this code
// example, no other constructors are exposed.
//
public WordDefKeyed() : base() { }
public WordDefKeyed(IEqualityComparer<string> comparer)
: base(comparer)
{
// what do I do here???????
}
// This is the only method that absolutely must be overridden,
// because without it the KeyedCollection cannot extract the
// keys from the items. The input parameter type is the
// second generic type argument, in this case OrderItem, and
// the return value type is the first generic type argument,
// in this case int.
//
protected override string GetKeyForItem(WordDef item)
{
// In this example, the key is the part number.
return item.Word;
}
}
private static Dictionary<string, int> stemDef = new Dictionary<string, int(StringComparer.OrdinalIgnoreCase); // this works this is what I want for KeyedCollection