Click here to Skip to main content
15,892,927 members
Home / Discussions / C#
   

C#

 
QuestionTCP Server Question *IMPORTANT* Pin
Serpendiem31-May-09 18:30
Serpendiem31-May-09 18:30 
AnswerRe: TCP Server Question *IMPORTANT* Pin
Jimmanuel1-Jun-09 2:45
Jimmanuel1-Jun-09 2:45 
Question[SOLVED] Future or past date time Pin
CodingLover31-May-09 18:02
CodingLover31-May-09 18:02 
AnswerRe: Future or past date time Pin
CodingLover31-May-09 18:05
CodingLover31-May-09 18:05 
QuestionBelow idea how to be realized in C#? Pin
mctramp16831-May-09 17:08
mctramp16831-May-09 17:08 
AnswerRe: Below idea how to be realized in C#? Pin
Christian Graus31-May-09 19:25
protectorChristian Graus31-May-09 19:25 
GeneralRe: Below idea how to be realized in C#? Pin
mctramp16831-May-09 20:13
mctramp16831-May-09 20:13 
GeneralRe: Below idea how to be realized in C#? Pin
Christian Graus31-May-09 21:48
protectorChristian Graus31-May-09 21:48 
GeneralRe: Below idea how to be realized in C#? Pin
mctramp16831-May-09 22:04
mctramp16831-May-09 22:04 
GeneralRe: Below idea how to be realized in C#? Pin
Pete O'Hanlon31-May-09 22:19
mvePete O'Hanlon31-May-09 22:19 
GeneralRe: Below idea how to be realized in C#? Pin
0x3c01-Jun-09 0:07
0x3c01-Jun-09 0:07 
GeneralRe: Below idea how to be realized in C#? Pin
mctramp1681-Jun-09 1:16
mctramp1681-Jun-09 1:16 
Questioncustom control textbox with a label tied Pin
Wendell.S31-May-09 16:21
Wendell.S31-May-09 16:21 
AnswerRe: custom control textbox with a label tied Pin
Dave Kreskowiak31-May-09 17:28
mveDave Kreskowiak31-May-09 17:28 
QuestionUltra-light native embedded database Pin
Pascal Ganaye31-May-09 10:27
Pascal Ganaye31-May-09 10:27 
AnswerRe: Ultra-light native embedded database Pin
Henry Minute31-May-09 11:07
Henry Minute31-May-09 11:07 
AnswerRe: Ultra-light native embedded database Pin
Garth J Lancaster31-May-09 12:02
professionalGarth J Lancaster31-May-09 12:02 
AnswerRe: Ultra-light native embedded database Pin
Joe Woodbury31-May-09 16:14
professionalJoe Woodbury31-May-09 16:14 
AnswerRe: Ultra-light native embedded database Pin
Pascal Ganaye1-Jun-09 13:41
Pascal Ganaye1-Jun-09 13:41 
Questionauto initialise all public fields in a class Pin
tig281031-May-09 10:09
tig281031-May-09 10:09 
Hi all

I’m looking for some assientance on auto initialising all public fields in a class.

I have a class with about 50+ fields. When an instance of the class is created and a value is assigned to the fields, it appends to the existing static value.

MyClass obj = new MyClass();
obj.Example = “THIS_STRING”; // This would therefore return STATIC_BEGINING_OF_STRINGTHIS_STRING which is desired.

My problem is that in obj.allRecords will only contain “STATIC_BEGINING_OF_STRINGTHIS_ STRING” and not “ANOTHER_STATIC_BEGINING_OF_STRING” plus the other 50 fields as they have not been initialised to their initial default value. I dont want to do it manually in the object as the point is that they are in the list as their default value even if unchanged.

Thanks for any help.

    class MyClass    {

        public MyClass() { }

        public List<string> allRecords = new List<string>();
        
        private string  _example = "STATIC_BEGINING_OF_STRING"; 
        public string Example
        {
            get { return _example; }
            set 
            {
                _example += value; 
                allRecords.Add(_example); 
            }
        }

// 50 more encapsulated fields

        private string _recordEnd = "ANOTHER_STATIC_BEGINING_OF_STRING";
        public string RecordEnd
        {
            get { return _recordEnd; }
            set 
            {
                _recordEnd += value;
                allRecords.Add(_recordEnd);
            }
        }
   }

AnswerRe: auto initialise all public fields in a class Pin
Henry Minute31-May-09 11:21
Henry Minute31-May-09 11:21 
GeneralRe: auto initialise all public fields in a class Pin
tig281031-May-09 11:29
tig281031-May-09 11:29 
GeneralRe: auto initialise all public fields in a class Pin
Henry Minute31-May-09 11:42
Henry Minute31-May-09 11:42 
GeneralRe: auto initialise all public fields in a class Pin
tig281031-May-09 14:02
tig281031-May-09 14:02 
AnswerRe: auto initialise all public fields in a class Pin
S. Senthil Kumar31-May-09 21:11
S. Senthil Kumar31-May-09 21:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.