bri189a Posted November 2, 2004 Posted November 2, 2004 I've been doing: Dim x as SomeClass = new SomeClass(operators) But I found accidently: Dim x as New SomeClass(operators) Is the first or second preferred .NET syntax...I've been using the first since it's similiar to C# syntax. Is one of them VB6? Quote
Administrators PlausiblyDamp Posted November 2, 2004 Administrators Posted November 2, 2004 Either work fine in VB.Net in fact all the following have the same end result Dim a As Object a = New Object Dim b As Object = New Object Dim c As New Object You found that in good quality VB6 code the first was the prefered method as doing the dim blah as new thing syntax in VB6 behaved differently to declaring and initialising on two lines (more importantly the difference was quite subtle until you were hit by a nasty bug or two) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.