2 properties into 1

  • Thread starter Thread starter csharpula csharp
  • Start date Start date
C

csharpula csharp

Hello,
I have a singletone class and 2 diffeerent properties there,I want to
aggrigate them together in a class .How can I do it? (code)
Thank you!
 
Hello,
I have a singletone class and 2 diffeerent properties there,I want to
aggrigate them together in a class .How can I do it? (code)
Thank you!

If I understood you correctly, one solution could be:

//the "aggregate class":
class TheSettings
{
private int _number;
private string _text;

public TheSettings(int Number, string Text)
{
_number = Number; _text = Text;
}
// skipped the properties for Number and Text
}

// the singleton
class TheSingleton
{
private int _aNumber;
private string _aText;

// skipped singleton code

public TheSettings AggregateSettings
{
get { return new TheSettings(_aNumber, _aText); }
set { _aNumber = value.Number; _aText = value.Text; }
}
}



Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top