On Tue, 4 Jun 2002 12:08:57 +1000, Rolls, Robert <[EMAIL PROTECTED]> wrote:
>Do people still use the constructor to define default values to members or >has the default constructor been depreciated? Are there any reasons not to >use to the following? > >public byte[] arr = new byte[1024]; > >rather than > >public byte[] arr = null; > >then within the constructor >arr = new byte[1024]; > > >Regards, >Robert Rolls Another minor point to add to Drew's is that you can only initialize a field at its point of declaration if the field is inside a class. If the field is inside a struct it won't work (unless of course the field is static). The general opinion seems to be that you should initialize non static fields in the constrctor. This leads to a follow on question...what are the pros and cons of initializing a static fields at its point of declaration vs in a static constructor? Cheers Jon Jagger You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.