hi
Can any one help me , can i initilize instance variable without constructor if it is possible than how , if it is not possible why what is the reason of that...?
Instance Memebers(Class level Members)
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.


VulpesRank #55 · 29.2K reputationPosted Jun 9, 2011, 12:30 AM EDT
class MyClass
{
public int MyInt = 3;
public string MyString = "Hello";
// etc
}
If you don't initialize them , then they have their default values of 0 (numbers), false (bool) or null (reference types).
Notice though that you can't do this for structs. You have to use the constructor.