15 out of 17 rated this helpful - Rate this topic

Constructors (C# Programming Guide)

Whenever a class or struct is created, its constructor is called. A class or struct may have multiple constructors that take different arguments. Constructors enable the programmer to set default values, limit instantiation, and write code that is flexible and easy to read. For more information and examples, see Using Constructors (C# Programming Guide) and Instance Constructors (C# Programming Guide).

If you do not provide a constructor for your object, C# will create one by default that instantiates the object and sets member variables to the default values as listed in Default Values Table (C# Reference). For more information and examples, see Instance Constructors (C# Programming Guide).

Static classes and structs can also have constructors. For more information and examples, see Static Constructors (C# Programming Guide).

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.