Click here to Skip to main content
15,906,463 members
Home / Discussions / C#
   

C#

 
AnswerRe: Text File Pin
PIEBALDconsult14-Nov-09 8:48
mvePIEBALDconsult14-Nov-09 8:48 
AnswerRe: Text File Pin
hosseinghazanfary14-Nov-09 20:02
hosseinghazanfary14-Nov-09 20:02 
GeneralRe: Text File Pin
Morgs Morgan15-Nov-09 4:17
Morgs Morgan15-Nov-09 4:17 
Questionclass vs structs in C# Pin
BobInNJ14-Nov-09 5:01
BobInNJ14-Nov-09 5:01 
AnswerRe: class vs structs in C# Pin
Shameel14-Nov-09 5:07
professionalShameel14-Nov-09 5:07 
GeneralRe: class vs structs in C# Pin
N a v a n e e t h14-Nov-09 6:49
N a v a n e e t h14-Nov-09 6:49 
GeneralRe: class vs structs in C# Pin
Shameel14-Nov-09 6:57
professionalShameel14-Nov-09 6:57 
AnswerRe: class vs structs in C# Pin
N a v a n e e t h14-Nov-09 6:43
N a v a n e e t h14-Nov-09 6:43 
BobInNJ wrote:
it does not.
This does not make any sense to me. Is there a reason for it?


A struct in C++ and C# is different. In C++, struct is used to represent PODs and in C# it is used for representing value types. In .NET, most of the objects will be allocated on the managed heap. But struct has got a possibility of getting allocated on the stack and CLR can't guarantee to zero out the locations each filed uses. If parameterless constructor is allowed, there will be problems in array allocation as well.

So it enforces all fields to be initialized and provide a default constructor that does this. This helps compiler to copy the values without worrying about uninitialized fields.

Smile | :)

Best wishes,
Navaneeth

GeneralRe: class vs structs in C# Pin
BobInNJ14-Nov-09 12:33
BobInNJ14-Nov-09 12:33 
GeneralRe: class vs structs in C# Pin
N a v a n e e t h14-Nov-09 17:32
N a v a n e e t h14-Nov-09 17:32 
AnswerRe: class vs structs in C# Pin
Richard MacCutchan14-Nov-09 6:55
mveRichard MacCutchan14-Nov-09 6:55 
AnswerRe: class vs structs in C# Pin
PIEBALDconsult14-Nov-09 8:52
mvePIEBALDconsult14-Nov-09 8:52 
GeneralRe: class vs structs in C# Pin
BobInNJ14-Nov-09 11:44
BobInNJ14-Nov-09 11:44 
GeneralRe: class vs structs in C# Pin
PIEBALDconsult15-Nov-09 3:51
mvePIEBALDconsult15-Nov-09 3:51 
Questionfind IP-Adress of external hardware (XPort) connected via Ethernet Pin
A_Wolf14-Nov-09 4:30
A_Wolf14-Nov-09 4:30 
AnswerRe: find IP-Adress of external hardware (XPort) connected via Ethernet Pin
Dave Kreskowiak14-Nov-09 11:13
mveDave Kreskowiak14-Nov-09 11:13 
QuestionHow to implement BarCode Reader in Customer inventry system using C#.net??? Pin
Arslan Khan14-Nov-09 3:05
Arslan Khan14-Nov-09 3:05 
AnswerRe: How to implement BarCode Reader in Customer inventry system using C#.net??? Pin
OriginalGriff14-Nov-09 4:47
mveOriginalGriff14-Nov-09 4:47 
GeneralRe: How to implement BarCode Reader in Customer inventry system using C#.net??? Pin
Arslan Khan14-Nov-09 5:20
Arslan Khan14-Nov-09 5:20 
GeneralRe: How to implement BarCode Reader in Customer inventry system using C#.net??? Pin
OriginalGriff14-Nov-09 5:34
mveOriginalGriff14-Nov-09 5:34 
GeneralRe: How to implement BarCode Reader in Customer inventry system using C#.net??? Pin
The Man from U.N.C.L.E.14-Nov-09 5:40
The Man from U.N.C.L.E.14-Nov-09 5:40 
AnswerRe: How to implement BarCode Reader in Customer inventry system using C#.net??? Pin
Jacob Lee16-Nov-14 15:13
Jacob Lee16-Nov-14 15:13 
Questionget the Event log Identity Pin
Jassim Rahma14-Nov-09 3:00
Jassim Rahma14-Nov-09 3:00 
AnswerRe: get the Event log Identity Pin
The Man from U.N.C.L.E.14-Nov-09 5:56
The Man from U.N.C.L.E.14-Nov-09 5:56 
QuestionTaskDialog without a button! Pin
Jassim Rahma14-Nov-09 2:58
Jassim Rahma14-Nov-09 2:58 

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.