How to use out in c#7 with visual studio 2017
In c#7 you can use out keyword in new way , let's take an example
i need to get my name by out keyword in c#6 your code will be like this
public static void OldWay()
{
string firstName;
string lastName;
MyName(out firstName, out lastName);
Console.WriteLine($"My Name is :{ firstName} {lastName} => Old way");
}
now in c#7 you don't need to define variables alone you just define it when you pass it to the method something like this
public static void CSharp7Way()
{
MyName(out string firstName, out string lastName);
Console.WriteLine($"My Name is :{ firstName} {lastName} => c#7 way");
}
when you run you will see the magic and the same result :)
you can find the all code here
Go ahead and try it :)
Senior Software Developer
7 年nice >>> go on man
Computer Instructor ~SST @FGEI(C/G) Schools System, Ministry of Defense, Pakistan
7 年nice information. thanks