Click here to Skip to main content
15,892,005 members
Home / Discussions / C#
   

C#

 
GeneralSelf Upgrading Executables (C# Windows App) Pin
OBRon1-Oct-03 9:45
OBRon1-Oct-03 9:45 
GeneralRe: Self Upgrading Executables (C# Windows App) Pin
SimonS2-Oct-03 1:24
SimonS2-Oct-03 1:24 
GeneralRe: Self Upgrading Executables (C# Windows App) Pin
OBRon2-Oct-03 2:54
OBRon2-Oct-03 2:54 
QuestionCOM Ports in C# - How ? Pin
raheela1-Oct-03 9:42
raheela1-Oct-03 9:42 
GeneralArray question Pin
Joe Woodbury1-Oct-03 7:56
professionalJoe Woodbury1-Oct-03 7:56 
GeneralRe: Array question Pin
jparsons1-Oct-03 9:20
jparsons1-Oct-03 9:20 
GeneralRe: Array question Pin
Joe Woodbury1-Oct-03 10:59
professionalJoe Woodbury1-Oct-03 10:59 
GeneralRe: Array question Pin
Frank Olorin Rizzi2-Oct-03 4:12
Frank Olorin Rizzi2-Oct-03 4:12 
Well...

<br />
static public Data data[] = {<br />
  new Data(0, "Zero"),<br />
  new Data(1, "One" ),<br />
  new Data(-1, NULL )};<br />


In a sense, it's the only logical thing to do (and allow)..
After all, in C# arrays are actually a type of their own
(unlike the older C style case where an array is just a
pointer).
So, while the first line begins the instanciation of a new
Array of Data, you still have to instanciate and initialize
each data (hence the other lines look like they do).

The longer version of the same code is (forgetting about static and public):
<br />
Data[] data = new Data[3];<br />
data[0] = new Data(0, "Zero");<br />
data[1] = new Data(1, "One");<br />
data[2] = new Data(-1, NULL);<br />


Until the second line, data[0] has not been instanciated to be
a Data object (yet, data[] has been instanciated to be an array of
Data objects that can accomodate 3 Data instances).

Might seem inefficient, but, thinking of the Data instances as objects
of their own right, it makes sense (sort-of)...
..sure, in your case they are structs, but I think that at this point they
just figured it was better to avoid a different syntax for structs vs classes...

I saw this situation in Java the first time,
and it took a bit to get used to it (yeah, I kept on thinking that
after Data[] data = new Data[3] all three data objects where instanciated,
pointing to NULL... again, they are not pointers!).

F.O.R.
GeneralRe: Array question Pin
jparsons2-Oct-03 5:29
jparsons2-Oct-03 5:29 
GeneralRe: Array question Pin
Julian Bucknall [MSFT]2-Oct-03 6:13
Julian Bucknall [MSFT]2-Oct-03 6:13 
GeneralRe: Array question Pin
Joe Woodbury2-Oct-03 6:40
professionalJoe Woodbury2-Oct-03 6:40 
GeneralInspiration needed - end user form editing Pin
Member 961-Oct-03 6:59
Member 961-Oct-03 6:59 
GeneralRe: Inspiration needed - end user form editing Pin
Michael P Butler2-Oct-03 1:42
Michael P Butler2-Oct-03 1:42 
GeneralRe: Inspiration needed - end user form editing Pin
Member 962-Oct-03 5:05
Member 962-Oct-03 5:05 
Generalremoting event problem Pin
manusha1-Oct-03 5:37
manusha1-Oct-03 5:37 
Generalimporting VB 6.0 into C# project... Pin
Anonymous1-Oct-03 4:47
Anonymous1-Oct-03 4:47 
GeneralGDI+ font and scalable graphics Pin
Member 5506441-Oct-03 2:33
Member 5506441-Oct-03 2:33 
GeneralRe: GDI+ font and scalable graphics Pin
Mazdak1-Oct-03 3:46
Mazdak1-Oct-03 3:46 
GeneralRe: GDI+ font and scalable graphics Pin
Member 5506441-Oct-03 4:03
Member 5506441-Oct-03 4:03 
GeneralRe: GDI+ font and scalable graphics Pin
azusakt1-Oct-03 15:21
azusakt1-Oct-03 15:21 
Generalthreading issue... Pin
profoundwhispers1-Oct-03 0:53
profoundwhispers1-Oct-03 0:53 
GeneralRe: threading issue... Pin
Blake Coverett1-Oct-03 1:50
Blake Coverett1-Oct-03 1:50 
GeneralRe: threading issue... Pin
profoundwhispers1-Oct-03 1:56
profoundwhispers1-Oct-03 1:56 
GeneralRe: threading issue... Pin
Blake Coverett1-Oct-03 8:22
Blake Coverett1-Oct-03 8:22 
GeneralEncryption/Decryption problem Pin
3ddA30-Sep-03 23:50
3ddA30-Sep-03 23:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.