About 840,000 results
Open links in new tab
  1. c# - Interface defining a constructor signature? - Stack Overflow

    While you can't define a constructor signature in an interface, I feel it's worth mentioning that this may be a spot to consider an abstract class. Abstract classes can define unimplemented …

  2. constructor - What is the best way to give a C# auto-property an ...

    In C# 5 and earlier, to give auto implemented properties an initial value, you have to do it in a constructor. Since C# 6.0, you can specify initial value in-line.

  3. c# - What's the difference between an object initializer and a ...

    A constructor is a defined method on a type which takes a specified number of parameters and is used to create and initialize an object. An object initializer is code that runs on an object after a …

  4. .net - Calling the base constructor in C# - Stack Overflow

    If you need to call the base constructor in the middle of the override, then extract it to an actual method on the base class that you can call explicitly. The assumption with base constructors is …

  5. c# - JSON.net: how to deserialize without using the default …

    I have a class that has a default constructor and also an overloaded constructor that takes in a set of parameters. These parameters match to fields on the object and are assigned on …

  6. c# - Code snippet or shortcut to create a constructor in Visual …

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

  7. How to do constructor chaining in C# - Stack Overflow

    I don't understand how constructor chaining works or how to implement it or even why it's better than just doing constructors without chaining. I would appreciate some examples with an …

  8. c# - Create instance of generic type whose constructor requires a ...

    Additionally a simpler example: return (T)Activator.CreateInstance(typeof(T), new object[] { weight }); Note that using the new () constraint on T is only to make the compiler check for a public …

  9. c# - Naming conventions for Constructor Arguments? - Stack …

    4 I always have an issue with similarities between the names of the Public variables in a class and the arguments I am passing into the same classes constructor. When you are defining a new …

  10. constructor - C# How to execute code after object construction ...

    I think pulling DoStuff out of the base class constructor and explicitely calling it is the most straightforeward approach, or providing a base class Init that can be overridden.