• 1404/09/16

تمرین گرفتن اطلاعات کاربر با کلاس :

Console.WriteLine("How many People are on Your List ?");
try
{
    int input = Convert.ToInt32(Console.ReadLine());

    string[] customers = new string[input];

    customer customer = new customer();

    for (int i = 0; i < input; i++)
    {
        Console.WriteLine($"enter name {i+1} : ");
        customer.name = Console.ReadLine();

        Console.WriteLine($"enter famili {i+1} :");
        customer.famili = Console.ReadLine();

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

        customers[i] = (customer.name + " " + customer.famili + " " + customer.phone);

    }
    for (int i = 0; i < input; i++)
    {
        Console.WriteLine("=============================");
        Console.WriteLine(customers[i]);
    }
}
catch
{
    Console.ForegroundColor = ConsoleColor.Red;
    Console.WriteLine("Please Enter The Number....!");
}
finally
{
    Console.ResetColor();
    Console.ReadKey();
}
  • 1404/09/16
  • ساعت 17:02

اشتباهه !

باید آرایه از نوع خود Customer باشه


logo-enamadlogo-samandehi