The field variables in a class or a struct in C# are by default given a value of zero

Skill/Topic: Beginner
A) True
B) False

Showing Answers 1 - 14 of 14 Answers

AmitMishra

  • Nov 29th, 2005
 

False, since you never no that your field variable is premitive data type. and other thing is all premitive datatypes are not necessarily of type int, double, decimal..

  Was this answer useful?  Yes

samiksc

  • Dec 6th, 2005
 

A value-type field variable is initialized to its default value, which is equal to the value computed by the value type's default constructor.

A reference type field variable is initialized to its default value, which is null.

All numeric type field variables are initialized to 0, bool is initialized to false, and string to empty string.

The field variables initialization is basically done by the memory manager by setting all memory bits to 0 before it is allocated for use.

  Was this answer useful?  Yes

JyeGuy

  • Mar 25th, 2007
 

This answer is marked incorrectly still. All field values are 'not' initialized to 0. As someone mentioned 2 years ago, booleans, for example, are initialized to false.

Bah, I want my point back.

  Was this answer useful?  Yes

mwelo

  • Jun 19th, 2009
 

The right answer is true not false!  The rules are slightly different between classes and structs...

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions