How to create a colletion of properties in a C# class
Hello folks,
Happy New Year!!!
I have a class that has couple of properties.
Can I have a property in that class that can be a collection. Like say the MarketData. can I have a property say "FailedCurves" . It is a string property. But only thing is, this property is an ArrayList or Dictionary object that can have multiple string items in it.
How can I do that in C#? Am I thinking correct?
Thanks much
Code:
public class MarketData
{
#region "Private Data Members"
private int _countAdvanceCurve;
private int _countAdvancesSBCAgencyCurve;
private int _countAdvancesSBCAAACurve;
private int _countFhlbsfTreasuryCurve;
private int _countDNCOCurve;
#endregion "Private Data Members"
#region "Public Data Members"
public int CountAdvanceCurve
{
get { return _countAdvanceCurve; }
set { _countAdvanceCurve = value; }
}
}
Re: How to create a colletion of properties in a C# class
You can surely return an object as a property:
Code:
class
{
private Dictionary<int, string> privateDict;
public Dictionary DictionaryProperty
{
get { return this.privateDict; }
set { this.privateDict = value; } //Or you can omit the setter, if you like
}
}