Click here to Skip to main content
15,897,704 members
Home / Discussions / C#
   

C#

 
AnswerRe: Why use a preprocessor variable instead of a normal one Pin
N a v a n e e t h5-Nov-07 18:42
N a v a n e e t h5-Nov-07 18:42 
AnswerRe: Why use a preprocessor variable instead of a normal one Pin
PIEBALDconsult6-Nov-07 4:02
mvePIEBALDconsult6-Nov-07 4:02 
QuestionHow to Validate an XML Document by Using DTD, XDR in C# window applications Pin
mrcsn5-Nov-07 17:31
mrcsn5-Nov-07 17:31 
AnswerRe: How to Validate an XML Document by Using DTD, XDR in C# window applications Pin
N a v a n e e t h5-Nov-07 18:43
N a v a n e e t h5-Nov-07 18:43 
QuestionWeb service error... Pin
Pankaj - Joshi5-Nov-07 17:27
Pankaj - Joshi5-Nov-07 17:27 
QuestionCopy file from server to local disk...... Pin
P_Elza5-Nov-07 16:20
P_Elza5-Nov-07 16:20 
AnswerRe: Copy file from server to local disk...... Pin
N a v a n e e t h5-Nov-07 19:29
N a v a n e e t h5-Nov-07 19:29 
QuestionHow can a struct with no explicit constructor have uninitialized fields? Pin
JoeRip5-Nov-07 14:37
JoeRip5-Nov-07 14:37 
The MSDN example at:

ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_cscomp/html/ba881e38-2abf-4a5f-b9e6-28d26a5bd235.htm

Shows the following code and says it will throw an "Error Message: Use of possibly unassigned field 'field'; A field in a structure was used without first being initialized."

// CS0170.cs<br />
public struct error<br />
{<br />
   public int i;<br />
}<br />
<br />
public class MyClass<br />
{<br />
   public static void Main()<br />
   {<br />
      error e;<br />
      // uncomment the next line to resolve this error<br />
      // e.i = 0;<br />
      System.Console.WriteLine( e.i );   // CS0170<br />
   }<br />
}


But it's my understanding that the compiler generated constructor for a struct automatically intializes the fields to zero, false, or null.

Since the struct in the example has no explicit constructor, why isn't i being initialized to zero?
AnswerRe: How can a struct with no explicit constructor have uninitialized fields? Pin
Luc Pattyn5-Nov-07 14:44
sitebuilderLuc Pattyn5-Nov-07 14:44 
GeneralRe: How can a struct with no explicit constructor have uninitialized fields? Pin
JoeRip5-Nov-07 14:46
JoeRip5-Nov-07 14:46 
GeneralRe: How can a struct with no explicit constructor have uninitialized fields? Pin
Luc Pattyn5-Nov-07 15:34
sitebuilderLuc Pattyn5-Nov-07 15:34 
AnswerRe: How can a struct with no explicit constructor have uninitialized fields? Pin
PIEBALDconsult5-Nov-07 14:47
mvePIEBALDconsult5-Nov-07 14:47 
GeneralRe: How can a struct with no explicit constructor have uninitialized fields? Pin
JoeRip5-Nov-07 14:51
JoeRip5-Nov-07 14:51 
GeneralRe: How can a struct with no explicit constructor have uninitialized fields? Pin
PIEBALDconsult5-Nov-07 16:19
mvePIEBALDconsult5-Nov-07 16:19 
QuestionUpdating Primary Key Pin
serene joey5-Nov-07 14:26
serene joey5-Nov-07 14:26 
AnswerRe: Updating Primary Key Pin
PIEBALDconsult5-Nov-07 16:23
mvePIEBALDconsult5-Nov-07 16:23 
QuestionRe: Updating Primary Key Pin
serene joey5-Nov-07 18:41
serene joey5-Nov-07 18:41 
AnswerRe: Updating Primary Key Pin
Andrei Ungureanu5-Nov-07 20:03
Andrei Ungureanu5-Nov-07 20:03 
GeneralRe: Updating Primary Key Pin
serene joey5-Nov-07 20:44
serene joey5-Nov-07 20:44 
GeneralRe: Updating Primary Key Pin
PIEBALDconsult6-Nov-07 4:05
mvePIEBALDconsult6-Nov-07 4:05 
GeneralRe: Updating Primary Key Pin
serene joey11-Nov-07 20:10
serene joey11-Nov-07 20:10 
QuestionHooking Direct Api Pin
danzar5-Nov-07 13:16
danzar5-Nov-07 13:16 
QuestionMaking Project Pin
Sameh96140335-Nov-07 11:30
Sameh96140335-Nov-07 11:30 
AnswerRe: Making Project Pin
Paul Conrad5-Nov-07 15:25
professionalPaul Conrad5-Nov-07 15:25 
QuestionData not stored on pocket pc Pin
karanjsingh5-Nov-07 11:19
karanjsingh5-Nov-07 11:19 

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.