By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,479 Members | 988 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,479 IT Pros & Developers. It's quick & easy.

Class member initial values.

P: n/a
Hello,

question about following code:

Class MariaBello
Private intCount As Integer = 0
Private objLauraLinney As New LauraLinney()
End Class

Class TylerDurden
Private intCount As Integer
Private objLauraLinney As LauraLinney
Public Sub New()
intCount = 0
objLauraLinney = New LauraLinney()
End Sub
End Class

Is there any difference between the 2 methods of giving intCount its value?
Exceptions may occure when creating a new object, so you could catch them
inside New(), but other than that, what is the prefered method of creating
the new object and why?

Thanks.

Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Qwert,

My prefered methods are those, which shows in the shortest way to another
one, (who is reading the program afterwards) (and myself too) what I did.

Just my thought,

Cor
Nov 21 '05 #2

P: n/a
"Qwert" <no**@nosp.com> schrieb:
Class MariaBello
Private intCount As Integer = 0
Private objLauraLinney As New LauraLinney()
End Class

Class TylerDurden
Private intCount As Integer
Private objLauraLinney As LauraLinney
Public Sub New()
intCount = 0
objLauraLinney = New LauraLinney()
End Sub
End Class

Is there any difference between the 2 methods of giving intCount its
value? Exceptions may occure when creating a new object, so you could
catch them inside New(), but other than that, what is the prefered method
of creating the new object and why?


I suggest to compare the IL emitted in both cases using the "ILDASM.EXE"
utility.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.