Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the "default values" that .Net sets all of the values in a class to if the class does not have a constructor?

In c# using .Net, if you create a class with an uninitialized field and without a constructor, then create an instance of the class with the new keyword, .Net sets the value of the field to the "default value". What exactly does that mean? Is there ever a situation where the value would be set to Null?

like image 944
Leigha Brown Avatar asked Dec 18 '22 15:12

Leigha Brown


1 Answers

Like Johnny mentioned in the comments, this table lists the default values for .NET types. The default value of a reference-type field is null.

like image 196
Joe Sewell Avatar answered Dec 24 '22 01:12

Joe Sewell