About 50 results
Open links in new tab
  1. What are the rules for calling the base class constructor?

    1190 Base class constructors are automatically called for you if they have no argument. If you want to call a superclass constructor with an argument, you must use the subclass's constructor initialization …

  2. What's the difference between an object initializer and a constructor?

    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 constructor …

  3. function - Purpose of a constructor in Java? - Stack Overflow

    Nov 13, 2013 · What is the purpose of a constructor? I've been learning Java in school and it seems to me like a constructor is largely redundant in things we've done thus far. It remains to be seen if a …

  4. oop - Constructors in JavaScript objects - Stack Overflow

    Jul 11, 2009 · Using Nick's sample above, you can create a constructor for objects without parameters using a return statement as the last statement in your object definition.

  5. .NET Core DI, ways of passing parameters to constructor

    Dec 21, 2018 · Having the following service constructor public class Service : IService { public Service(IOtherService service1, IAnotherOne service2, string arg) { } } What are the choices of

  6. Constructor of an abstract class in C# - Stack Overflow

    Mar 15, 2015 · An abstract class constructor c# code example will be explained. But, the next question can also be arises, as if we cannot instantiate (construct an object using new) an abstract class, then …

  7. c++ - Initializing fields in constructor - initializer list vs ...

    6 In your example code, the first one in constructor initialization and second one is assignment inside constructor body. Constructor initialization list is the best way to do all member initialization because …

  8. Java Constructors - Stack Overflow

    Aug 21, 2016 · The constructor arguments allow you to provide parameters for the initialization of an object. In this example, you can create a Bicycle object with a gear of 1, cadence of 0, and a speed …

  9. .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 that they're …

  10. c# - Call asynchronous method in constructor? - Stack Overflow

    Apr 14, 2014 · By making the constructor private and keeping the static method within the same class we have made sure that no one could "accidentally" create an instance of this class without calling …