tagged [constructor]

Can I call an overloaded constructor from another constructor of the same class in C#?

Can I call an overloaded constructor from another constructor of the same class in C#? Can I call an overloaded constructor from another constructor of the same class in C#?

3 Apr at 17:51

Set properties of a class only through constructor

Set properties of a class only through constructor I am trying to make the properties of class which can only be set through the constructor of the same class.

17 Dec at 20:29

Form constructor vs Form_Load

Form constructor vs Form_Load Whats the difference between a form constructor and the form_Load method? Whats your though process for placing items in one vs the other?

12 Apr at 16:55

Code snippet or shortcut to create a constructor in Visual Studio

Code snippet or shortcut to create a constructor in Visual Studio What is the code snippet or shortcut for creating a constructor in Visual Studio? Visual Studio 2010 and C#.

Kotlin secondary constructor

Kotlin secondary constructor How do I declare a secondary constructor in Kotlin? Is there any documentation about that? Following does not compile...

10 Oct at 15:7

Virtual member call in a constructor

Virtual member call in a constructor I'm getting a warning from ReSharper about a call to a virtual member from my objects constructor. Why would this be something not to do?

What setup code should go in Form Constructors versus Form Load event?

What setup code should go in Form Constructors versus Form Load event? For winforms applications I'm wondering what setup code should go in: - as opposed to - Are there any best practice guidelines he...

15 Mar at 06:53

Static constructors cause a performance overhead?

Static constructors cause a performance overhead? Recently read in a article on dotnetpearls.com [here](http://dotnetperls.com/static-constructor) saying that static ctors take a substantial amount of...

15 Nov at 07:30

Constructor on type not found

Constructor on type not found Exception Message: `Constructor on type StateLog not found`. I have the following code that does not work for only one class: ``` List list = new List(); string line;...

29 Aug at 23:54

protected vs public constructor for abstract class? Is there a difference?

protected vs public constructor for abstract class? Is there a difference? This question is out of curiosity. Is there a difference between: and Thanks.

26 Dec at 00:1

When is a custom attribute's constructor run?

When is a custom attribute's constructor run? When is it run? Does it run for each object to which I apply it, or just once? Can it do anything, or its actions are restricted?

6 Aug at 18:49

What is the difference between static, internal and public constructors?

What is the difference between static, internal and public constructors? What is the difference between static, internal and public constructors? Why do we need to create all of them together?

Why doesn't C# support the concept of Copy Constructor?

Why doesn't C# support the concept of Copy Constructor? I was asked this question in one of my interviews, but I wasn't able to find out exactly why this concept is not there. Please let me know.

16 Sep at 18:17

C# static class constructor

C# static class constructor Is there a work around on how to create a constructor for static class? I need some data to be loaded when the class is initialized but I need one and only one object.

21 Sep at 07:45

Public constructor and static constructor

Public constructor and static constructor I am reading a code in C# that uses two constructors. One is static and the other is public. What is the difference between these two constructors? And for wh...

8 Jun at 07:31

Static constructor in C#

Static constructor in C# I am trying to use a static constructor like the following: and getting this error: > access modifiers are not allowed on static constructors I would like to know what's my pr...

22 Apr at 08:44

Why does the parameterless Guid constructor generate an empty GUID?

Why does the parameterless Guid constructor generate an empty GUID? Why does the parameterless Guid constructor generate an empty GUID rather than default to a generated one as with Guid.NewGuid()? Is...

30 Dec at 20:45

How to call protected constructor in c#?

How to call protected constructor in c#? How to call protected constructor? This obviously fails test:

15 Aug at 05:43

Inheriting constructors

Inheriting constructors Why does this code: Result in these errors: Shouldn't B inherit A's constructor? (this is using gcc)

7 Mar at 06:39

Throwing ArgumentNullException in constructor?

Throwing ArgumentNullException in constructor? For a constructor with a single parameter, is it OK to throw an ArgumentNullException inside the constructor if the parameter is null/empty? OR, should i...

Constructor of an abstract class in C#

Constructor of an abstract class in C# Why is it possible to write constructor for an abstract class in C#? As far as I know we can't instantiate an abstract class.. so what is it for? You can't insta...

15 Mar at 12:41

Is it possible to override a constructor in C#?

Is it possible to override a constructor in C#? Is it possible to override the constructor of the base class in the derived class? If so, the how can it be accomplished and in what use case would this...

7 Aug at 13:37

base() and this() constructors best practices

base() and this() constructors best practices Under what conditions am I supposed to make the `:base()` and `:this()` constructor calls following my constructor's parentheses (or even in other places ...

How do I check if a type provides a parameterless constructor?

How do I check if a type provides a parameterless constructor? I'd like to check if a type that is known at runtime provides a parameterless constructor. The `Type` class did not yield anything promis...

23 Apr at 05:52

How to disable parameterless constructor in C#

How to disable parameterless constructor in C# For the class CBase, it should be initialized by providing the parameter, so how to disable the parameterless constructor for CBase class?