Click here to Skip to main content
15,894,291 members
Home / Discussions / C#
   

C#

 
GeneralRe: play a movie Pin
kornstyle25-Aug-04 5:56
kornstyle25-Aug-04 5:56 
GeneralConvert vs parse Pin
Not Active25-Aug-04 3:27
mentorNot Active25-Aug-04 3:27 
GeneralRe: Convert vs parse Pin
LongRange.Shooter25-Aug-04 4:13
LongRange.Shooter25-Aug-04 4:13 
GeneralRe: Convert vs parse Pin
Norman-Timo25-Aug-04 4:20
Norman-Timo25-Aug-04 4:20 
GeneralRe: Convert vs parse Pin
Charlie Williams25-Aug-04 4:53
Charlie Williams25-Aug-04 4:53 
GeneralRe: Convert vs parse Pin
Nick Parker25-Aug-04 5:20
protectorNick Parker25-Aug-04 5:20 
GeneralRe: Convert vs parse Pin
Not Active25-Aug-04 6:00
mentorNot Active25-Aug-04 6:00 
GeneralClass field initialisation question. Pin
Dr Herbie25-Aug-04 3:21
Dr Herbie25-Aug-04 3:21 
Hi folks,
OK, what I'm interested in are the technical pros and cons of data initialisation in a classes.
I.e. which is better?

class Test<br />
{<br />
    private int mInt = -1;<br />
    Test()<br />
    {<br />
        // Do nothing<br />
    }<br />
}

or

class Test<br />
{<br />
    private int mInt;<br />
    Test()<br />
    {<br />
        mInt = -1;<br />
    }<br />
}



The reason I ask is that I usually have several constructors on my classes and I prefer the first method so I can guarantee that whichever constructor I'm entering, all the fields are initialised the same way.
But are there technical reasons not to do this?

Dr Herbie
Remember, half the people out there have below average IQs.
GeneralRe: Class field initialisation question. Pin
Norman-Timo25-Aug-04 3:29
Norman-Timo25-Aug-04 3:29 
GeneralRe: Class field initialisation question. Pin
Not Active25-Aug-04 3:34
mentorNot Active25-Aug-04 3:34 
GeneralRe: Class field initialisation question. Pin
leppie25-Aug-04 5:09
leppie25-Aug-04 5:09 
GeneralRe: Class field initialisation question. Pin
Nick Parker25-Aug-04 5:26
protectorNick Parker25-Aug-04 5:26 
GeneralRe: Class field initialisation question. Pin
Heath Stewart25-Aug-04 9:27
protectorHeath Stewart25-Aug-04 9:27 
GeneralThank You Pin
Dr Herbie25-Aug-04 22:08
Dr Herbie25-Aug-04 22:08 
GeneralExcel 2003 Custom Toolbar Flickers when any VBA Macro runs in the Excel Contest Pin
kellap25-Aug-04 1:54
kellap25-Aug-04 1:54 
GeneralOffice Excel 2003 with Information Bridge Framwork Pin
kellap25-Aug-04 1:50
kellap25-Aug-04 1:50 
GeneralRe: Office Excel 2003 with Information Bridge Framwork Pin
Heath Stewart25-Aug-04 9:33
protectorHeath Stewart25-Aug-04 9:33 
GeneralException in web services Pin
Diego F.25-Aug-04 0:18
Diego F.25-Aug-04 0:18 
GeneralRe: Exception in web services Pin
Salil Khedkar25-Aug-04 2:54
Salil Khedkar25-Aug-04 2:54 
GeneralRe: Exception in web services Pin
Salil Khedkar25-Aug-04 2:59
Salil Khedkar25-Aug-04 2:59 
GeneralRe: Exception in web services Pin
Nick Parker25-Aug-04 5:37
protectorNick Parker25-Aug-04 5:37 
GeneralCheck if TCP/IP partner disconnected... Pin
Norman-Timo24-Aug-04 23:18
Norman-Timo24-Aug-04 23:18 
GeneralRe: Check if TCP/IP partner disconnected... Pin
leppie25-Aug-04 1:45
leppie25-Aug-04 1:45 
GeneralRe: Check if TCP/IP partner disconnected... Pin
Norman-Timo25-Aug-04 3:16
Norman-Timo25-Aug-04 3:16 
GeneralRe: Check if TCP/IP partner disconnected... Pin
Sebastian Schneider25-Aug-04 4:54
Sebastian Schneider25-Aug-04 4:54 

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.