Khalil Khalil - 1 month ago 4x
C# Question

How to call a method that takes multiple parameters in c#

i am new at c# and i have a problem in this small program
i want to return the entered information in method ClientsDetails to use them in method Print().
Any help plz ?

public static void Main(string[] args)





public static void ClientsDetails()
Console.Write("Client's first name: ");
string firstName = Console.ReadLine();
Console.Write("Client's last name: ");
string lastName = Console.ReadLine();
Console.Write("Client's birthdate: ");
string birthday = Console.ReadLine();

public static void Print(string first, string last, string birthday)
Console.WriteLine("Client : {0} {1} was born on: {2}", first, last, Birthday);

mok mok

There is a heap of way that you can pass the required arguments to your method, so for example simply you can do it like this:

String f = "first string";
String l = "last string";
String b = "birthday string";

BTW, in your case it seems that you want the user's inputs to be passed to the Print method, so a simple way is to just call the Print method inside your ClientsDetails method like this:

Print(firstName, lastName, birthday);

For a comprehensive resource about this, you can refer to the docs, as always. At the moment you can just neglect the Async Methods part.