Constructors
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

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 allow the programmer to set default values, limit instantiation, and write code that is flexible and easy to read.

If you do not provide a constructor for your object, C# will create one by default that instantiates the object and sets any member variables to the default values listed here: Default Values Table (C# Reference). Static classes and structs can also have constructors.

In This Section

Related Sections

Show:
© 2016 Microsoft