2
Reply

when destructor will call ?

vijay channe

vijay channe

14y
3.6k
0
Reply

    static is used to create only and only one copy of Method/ Variable (not all just but declared with  static keyword)  for all Objects.

    Normally wat happen that if you create Two objects of One Class A. Two instances ( copies) will be create seprately.

    Suppose you are making a Car Racing game .You created the Class for Car. now you Created  some Objects of car in the Race .

    Class Car

    {

    int Power,

    int Color;

    int MaxSpeed,

    int RaceTime;

    int RankOneTime;//

     

    }

     

    In this Scenrio the Race Time should be RankOneTime should be same for all the cars because its Time of First Ranked Car.

    so you should Declare is As Static.

    Class Car

    {

    int Power,

    int Color;

    int MaxSpeed,

    int RaceTime;

    static int RankOneTime;

     

    }

    There is no time in a C# program ,when destructor is called.