string[] _myStrings = { "Hello", "There", "Happy", "Day" };
public IEnumerable<string> MyStrings1
{
get
{
return new System.Collections.ObjectModel.ReadOnlyCollection<string>(_myStrings);
}
}
public IEnumerable<string> MyStrings2
{
get
{
return from s in _myStrings select s;
}
}
मैंने सार्वजनिक गुणों के लिए सरणी का उपयोग न करने के बारे में कुछ चर्चा देखी है। मैं MyStrings2
कन्वेंशन का उपयोग कर रहा हूं। क्या मुझे कोई कारण है कि मुझे MyStrings1
का उपयोग करना चाहिए?ReadOnlyCollection IENumerable
संभव डुप्लिकेट [ReadOnlyCollection या सदस्य संग्रह को उजागर करने के लिए IEnumerable?] (Http://stackoverflow.com/questions/491375/readonlycollection-or-ienumerable-for-exposing-member-collections) – nawfal