Monday, April 30, 2012

Constructors


Constructors are special member functions, which are used for initializing the
class data members. In the earlier object oriented programming languages
constructors were quite important since initialization of the data members was
not allowed at the time of declaration. C# however allows us to have the member
variables to be initialized along with declarations. Then why are constructors
required? Well, the variables may not always be initialized to some constants but
can also be initialized with the values specified by the user. There can also be
certain kind of processing to be done while a class is instantiated. So a
constructor happens to be quite important member function in the class as far as
initialization is concerned.
C# supports following types of constructors
• Default Constructors
• Parameterized constructors
• Private constructors
• Static constructors

No comments:

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...