i have 2 child class and 1 mother class. i defined a rand object in mother and i called it in childs but its doesn't work properly. both int are the same. i want to assign different value
class Mother
{
public int sayi;
public Random rand = new Random();
static void Main(string[] args)
{
ChildFirst firsCh = new ChildFirst();
ChildSecond secondCh = new ChildSecond();
Console.ReadKey();
}
}
class ChildFirst : Mother
{ public ChildFirst() { sayi = rand.Next(1, 100); Console.WriteLine("Random int is: " + sayi); } }
class ChildSecond : Mother
{ public ChildSecond() { sayi = rand.Next(1, 100); Console.WriteLine("Random int is: " + sayi); } }
Aucun commentaire:
Enregistrer un commentaire