Suppose I initialize members of a class like this:
class A
{
public int i=4;
public double j=6.0;
}
Does the compiler generate a default constructor in this situation?
In general, I know that a constructor may initialize the value of class instance variables and may also perform some other initialization operations appropriate for the class. But in the above example, I have initialized the value of i and j outside of a constructor. In this situation, does the compiler still generate a default constructor? If so, what does the default constructor do?
The compiler still generates a default constructor in this case. The constructor handles the initialization of i and j. If you look at the IL this is evident.