1
Answer

How to call a cosntructor from anthor

Dillon Samuels

Dillon Samuels

15y
2.2k
1

Hi,

I have two constructors of a class, each takes an object of two forms as arguments. But each has one object of another class as common.

X obj = new X();

obj is should be common to all constructors. Therefore i need to create another constructor that initializes the "obj" but i need each of the overlaoded  constructors make calls to the constructor that initializes "obj".

public class Controller{

X obj;

 

//overlaoded constructor 1

public Controller(frmForm frm){

   frm.tbxLastName.text = "XYZ";

   //i need to make calls to the default constructor form here

 

}

public Controller(frmForm frm){

   frm.tbx.Country = "sdfsfs";

//I need to make calls to the defualt cosntructor from here

}

public Controller(){

   obj = new X();

}

}

How do i call the defualt constructor form each overloaded cosntructor?

 

cheers

 

Answers (1)