• 1405/05/20

تمرین class تا جلسه 28 :

Console.WriteLine("enter phone number:...");

string input = Console.ReadLine();

int inputc = Convert.ToInt32(input);

phone[] phones = new phone[inputc];

for(int i=0;i<inputc;i++)

{

   phone poh = new phone();

   Console.WriteLine($"enter phone name{i+1}:...");

   poh.name = Console.ReadLine();

   Console.WriteLine($"enter phone brand{i+1}:...");

   poh.brand = Console.ReadLine();

   Console.WriteLine($"enter ohine price{i+1}:...");

   poh.price = Convert.ToInt32(Console.ReadLine());

   phones[i] = poh;

}

Console.WriteLine("-------------------------");

int count = 1;

foreach(var ph in phones)

{

   Console.ForegroundColor=ConsoleColor.Green;

   Console.WriteLine($"phone{count}=> name:{ph.name}/brand:{ph.brand}/price:{ph.price}");

   count++;

   Console.ResetColor();

}

 

 

class phone

{

   public string name;

   public string brand;

   public int price;

 

}

 

  • 1405/05/21
  • ساعت 08:48

عالی