469,358 Members | 1,611 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,358 developers. It's quick & easy.

New Oject() {} vs. New Object(-1) {}

This has bugged me for some time.

Is there any "behind the scenes" difference between the following two
snippets?
Dim obj1 As Object = New Oject() {}
Dim obj2 As Object = New Object(-1) {}
Thanks!
Nov 21 '05 #1
4 7856
Apart from the obvious typos', I would suggest that there is no significant
difference.

Try:

Dim obj1() As Object = New Object() {}
Dim obj2() As Object = New Object(-1) {}
Console.WriteLine(obj1.Length)
Console.WriteLine(obj1.GetLowerBound(0))
Console.WriteLine(obj1.GetUpperBound(0))
Console.WriteLine(obj2.Length)
Console.WriteLine(obj2.GetLowerBound(0))
Console.WriteLine(obj2.GetUpperBound(0))

and observe the results.
"stand__sure" <st*********@hotmail.com> wrote in message
news:d4**********@domitilla.aioe.org...
This has bugged me for some time.

Is there any "behind the scenes" difference between the following two
snippets?
Dim obj1 As Object = New Oject() {}
Dim obj2 As Object = New Object(-1) {}
Thanks!

Nov 21 '05 #2
"stand__sure" <st*********@hotmail.com> schrieb:
This has bugged me for some time.

Is there any "behind the scenes" difference between the following two
snippets?
Dim obj1 As Object = New Oject() {}
Dim obj2 As Object = New Object(-1) {}


After some corrections ('obj1()', 'obj2()', 'Oject' -> 'Object') there is no
difference, not even behind the scenes, between the two lines.

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

Nov 21 '05 #3
Thanks for the replies (and for tolerance of the typo).

I had seen no difference in the debugger, but the guidance from microsoft
was to use "New Object(-1) {}" to create an empty array -- the form "New
Object() {}" is more intuitive...

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ut**************@TK2MSFTNGP12.phx.gbl...
"stand__sure" <st*********@hotmail.com> schrieb:
This has bugged me for some time.

Is there any "behind the scenes" difference between the following two
snippets?
Dim obj1 As Object = New Oject() {}
Dim obj2 As Object = New Object(-1) {}


After some corrections ('obj1()', 'obj2()', 'Oject' -> 'Object') there is
no difference, not even behind the scenes, between the two lines.

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

Nov 21 '05 #4
"stand__sure" <st*********@hotmail.com> schrieb:
Thanks for the replies (and for tolerance of the typo).

I had seen no difference in the debugger, but the guidance from microsoft
was to use "New Object(-1) {}" to create an empty array -- the form "New
Object() {}" is more intuitive...


I'd use the latter form.

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

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by ElanKathir | last post: by
3 posts views Thread by parthivjoshi | last post: by
1 post views Thread by Ramkumar T via DotNetMonster.com | last post: by
3 posts views Thread by Tracey | last post: by
reply views Thread by mhodkin | last post: by
9 posts views Thread by =?Utf-8?B?U0FM?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.