473,586 Members | 2,495 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What does this do? Object[0]

Object MyOnject = new Object[0];

What does the [0] signify?
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

Nov 15 '05 #1
12 11191


"Chad Z. Hower aka Kudzu" <cp**@hower.org > wrote in message
news:Xn******** **********@127. 0.0.1...
Object MyOnject = new Object[0];

What does the [0] signify?


Hi Chad,

It means you instantiated an array of type object with a Length of zero.

Joe
--
http://www.csharp-station.com
Nov 15 '05 #2
"Joe Mayo [MVP C#]" <jm***@nospamAt CSharpDashStati on.com> wrote in
news:u8******** ******@TK2MSFTN GP11.phx.gbl:
What does the [0] signify?

It means you instantiated an array of type object with a Length of zero.


Aah. That makes sense. I guess the placement and the fact that I was looking
for a constructor in its place threw me.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

Nov 15 '05 #3

"Joe Mayo [MVP C#]" <jm***@nospamAt CSharpDashStati on.com> wrote in message
news:u8******** ******@TK2MSFTN GP11.phx.gbl...


"Chad Z. Hower aka Kudzu" <cp**@hower.org > wrote in message
news:Xn******** **********@127. 0.0.1...
Object MyOnject = new Object[0];

What does the [0] signify?
Hi Chad,

It means you instantiated an array of type object with a Length of zero.

Which, because it isn't immediately obvious, works because an array of
object(object[]) is still derived from object and will assign without
complaint. Joe
--
http://www.csharp-station.com

Nov 15 '05 #4
Daniel O'Connell [C# MVP] <onyxkirx@--NOSPAM--comcast.net> wrote:
Which, because it isn't immediately obvious, works because an array of
object(object[]) is still derived from object and will assign without
complaint.


Indeed. If I saw a line of code like that in production source, I'd
definitely be suspicious - there'd have to be a good reason for the
variable not to be declared as object[] instead of object.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #5

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Daniel O'Connell [C# MVP] <onyxkirx@--NOSPAM--comcast.net> wrote:
Which, because it isn't immediately obvious, works because an array of
object(object[]) is still derived from object and will assign without
complaint.
Indeed. If I saw a line of code like that in production source, I'd
definitely be suspicious - there'd have to be a good reason for the
variable not to be declared as object[] instead of object.


As would I, the only use I could think of would be future proofing against
arrays == overload, and that is still a horrid construct.
object[] o = new object[0];

if (((object)o) == ((object)<whate ver>))

seems far better to me.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #6
Jon Skeet [C# MVP] <sk***@pobox.co m> wrote in
news:MP******** *************** *@msnews.micros oft.com:
Indeed. If I saw a line of code like that in production source, I'd
definitely be suspicious - there'd have to be a good reason for the
variable not to be declared as object[] instead of object.


Well I found it in MSDN in, in sample code. :)

I changed it to Object() anyways. It was only being used for a Monitor and
nothing else.

I suspet they were trying to save a few bytes, but it just doesnt seem a
clean approach. Some prior C developer probably.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

Nov 15 '05 #7

"Chad Z. Hower aka Kudzu" <cp**@hower.org > wrote in message
news:Xn******** **********@127. 0.0.1...
Jon Skeet [C# MVP] <sk***@pobox.co m> wrote in
news:MP******** *************** *@msnews.micros oft.com:
Indeed. If I saw a line of code like that in production source, I'd
definitely be suspicious - there'd have to be a good reason for the
variable not to be declared as object[] instead of object.
Well I found it in MSDN in, in sample code. :)


Which sample was it? Something is very odd about that...
I changed it to Object() anyways. It was only being used for a Monitor and
nothing else.

I suspet they were trying to save a few bytes, but it just doesnt seem a
clean approach. Some prior C developer probably.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

Nov 15 '05 #8
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
news:ua******** ******@TK2MSFTN GP09.phx.gbl:
Which sample was it? Something is very odd about that...


http://msdn.microsoft.com/library/de...l=/library/en-
us/cpguide/html/cpconASynchrono usFileIO.asp

public static Object NumImagesMutex = new Object[0];

This line also looks suspicious:

fs.BeginRead(st ate.pixels, 0, numPixels, readImageCallba ck,
state);

Is it my imagination or is the call back not being referenced correctly? Such
has never compiled in my code...
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

Nov 15 '05 #9

"Chad Z. Hower aka Kudzu" <cp**@hower.org > wrote in message
news:Xn******** **********@127. 0.0.1...
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
news:ua******** ******@TK2MSFTN GP09.phx.gbl:
Which sample was it? Something is very odd about that...
http://msdn.microsoft.com/library/de...l=/library/en-
us/cpguide/html/cpconASynchrono usFileIO.asp

public static Object NumImagesMutex = new Object[0];


This is really strange, unless there is(was) a bug in object itself that I'm
not aware of this is a strange construct. An array of type object, even with
no members probably takes up more memory space than an empty object. I
really wonder what the point was...

This line also looks suspicious:

fs.BeginRead(st ate.pixels, 0, numPixels, readImageCallba ck,
state);

Is it my imagination or is the call back not being referenced correctly? Such has never compiled in my code...
The callback is ok, although the ease of reading of this code sucks(for
non-colored code I like a little space inbetween comments and code), there
is a variable near the top of the method defined as:
AsyncCallback readImageCallba ck = new
AsyncCallback(R eadInImageCallb ack);

which is perfectly ok, a delegate is just an object afterall.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

Nov 15 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
18938
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it...
100
5208
by: E. Robert Tisdale | last post by:
What is an object? Where did this term come from? Does it have any relation to the objects in "object oriented programming"?
21
13810
by: Helge Jensen | last post by:
I've got some data that has Set structure, that is membership, insert and delete is fast (O(1), hashing). I can't find a System.Collections interface that matches the operations naturally offered by Sets. - ICollection cannot decide containment - IList promises indexability by the natural numbers, which is not achievable (since i hash...
13
5029
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
4
39974
by: Rachel Suddeth | last post by:
What is the difference between a managed/unmanaged resource, and how do you tell which is which? I'm trying to understand how to write some Dispose() methods, and we are supposed to put code that deals with managed in one place, and code that deals with unmanaged in another place, but I can't seem to find anything that clearly explains what...
19
2877
by: Charles Law | last post by:
Take a solution with a project hierarchy along the lines of an n-tier system, so that we have a data layer, business layer and presentation layer. The presentation layer is coupled to the business layer, and the business layer is coupled to the data layer. So far so good. Suppose the data layer raises an event, and it passes Me (the sender)...
9
3092
by: pamelafluente | last post by:
Hi, I was "studying" the famous (public code) BusyBox. I see the instruction: var busyBox = new BusyBox as in var busyBox = new BusyBox("BusyBox1", "busyBox", 4, "gears_ani_", ".gif", 125, 147, 206)
5
2229
by: Daz | last post by:
Hi everyone. My query is very straight forward (I think). What's the difference between someFunc.blah = function(){ ; } and
4
6679
by: grizggg | last post by:
I have searched and not found an answer to this question. I ran upon the following statement in a *.cpp file in a member function: static const char * const pacz_HTMLContentTypeHeader = "Content-Type: text/html\r\n"; Why is the second const needed and what does it do? Thanks
167
8239
by: darren | last post by:
Hi I have to write a multi-threaded program. I decided to take an OO approach to it. I had the idea to wrap up all of the thread functions in a mix-in class called Threadable. Then when an object should run in its own thread, it should implement this mix-in class. Does this sound like plausible design decision? I'm surprised that C++...
0
7915
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7841
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8204
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7965
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3838
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.