One constructor should be enough. Make the string parameter as optional. public class TestClass{public TestClass(string strTest = null){// Your code}}
Two. Once you write at least one constructor, The compiler cancels the freebie constructor, and now you have to write one yourself, even if there’s no implementation in it.
Whenever a class is created a constructor is called, and this default constructor is invoked when object of the class is created but Once we create a parameterized constructor, the class no more provides the default constructor. Therefore, in this case, we need to write two constructor, one with a string as parameter and another without parameter.
You have to write Two constructor One for Default Constructor, and another constructor with a string parameter
2
One constructor possible developers class Program{static void Main(string[] args){Employee p = new Employee("effewdf");Employee pe = new Employee();}}public class Employee{public Employee(string s=""){ }}
According to oops, by default a class will have default constructor until you didn't create any parameterized. If u create any parameterized you need to create zero perameterized constructor explicitly.
It depends on your usage. If you want some values to be initialized while creating an object for a class. Then you should consider parameterized constructor or if you want that initialization to be optional then you should have both default and parameterized constructor in your class.
Write Two constructor First-Parameterized Constructor and Second- Blank Constructor
There will be two constructors needed, One with no parameter and other with a string parameter
Two. You can create first constructor without parameter and second one constructor with parameter.
You need to have two different constructors. One is with parameter and another one without parameter.
You must Define Two constructor Like this Class A {public A(){}public A(string str){} }
you can create a function (no need to declare constructor ) , after it call this method in default constructor ::: :) :)
1
default constructor is also a parameter less constructor ex:- class Prashant { public Prashant(){} }
You need two constructors
There will be two constructors needed, One with no parameter and other with a string parameter.
Two. I think this is handled by the compiler. If you open the .net assembly in ILDASM you will see the default constructor, even if it is not in the code. If you define a parameterized constructor the default constructor will not bee seen.Actually when you define the class (non static), the compiler provides this feature thinking that you will be just creating an instance. And if you want any specific operation to perform you surely will be having your own constructor.
In the case you are taking about You have to write at least two constructor because once you write any constructor with any params then compiler will search for the default one. Else if you dont create a parameterize one you don't need to create a default constructor.
If you create a parameterized contructor you will have to create the default constructor too if you need it.
Only one constructor
HP,IBM,Tandberg Tape drive Repair and Backup company Pertho Engineers is a growing LTO Tape Drive repair and backup service provider company in india.We at Pertho Engineers also provide you LTO-3, LTO-4, LTO-5, LTO-6, LTO-7 Tape Drive repair and backup services in UAE. Pertho Engineers provides all company LTO Tape Drive repair and backup services in UAE. The leading companies whom repair and backup services are HP, IBM, Certance LTO, Quantum LTO, Tandberg LTO, Quantum DLT, Quantum VS80 VS160, Quantum SDLT, HP DAT DDS, Sony DAT DDS. Contact us 9871495530. http://serverntapedrive.com/hp-ibm-tandberg-tape-drive-repair-backup-company/http://i1152.photobucket.com/albums/p494/serverntapedrive/HPIBMTandberg%20Tape%20drive%20Repair%20and%20Backup%20company_zpsud12jltc.jpg
two constructor
One is sufficient.class Program{static void Main(string[] args){Employee p = new Employee("effewdf");Employee pe = new Employee();}}public class Employee{public Employee(string s=""){ }}
2 constructors ,First-parameterised Constructor and Second- public default Constructor
You will have to write two constructors, both parameter and non parameter(default) type.
Two constructors u hv to define one is by passing String as a parameter, and one more u hv to declare default constructor without arguments bcz once u define any constructor Thn compiler won't provide default constructor so the scenario , wen u want to declare parameterized constructor n default constructor as well Thn u hv to do it explicitly.
Two One the default one and second with the string parameter.
anyone you can do either make two constructor one is default with parameter and second with parameteror One constructor with optional Parameter