-
January 2nd, 2013, 06:55 PM
#1
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; }
}
}
-
January 2nd, 2013, 09:31 PM
#2
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
}
}
Best Regards,
BioPhysEngr
http://blog.biophysengr.net
--
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|