-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04OutParams.cs
More file actions
33 lines (26 loc) · 824 Bytes
/
04OutParams.cs
File metadata and controls
33 lines (26 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
namespace CSharp7Console
{
public class OutParams
{
public static void GetDetails(out int userId, out string username)
{
userId = 12;
username = "Test User";
}
private static void OutParamsExample()
{
//As it currently stands
int userId;
string userName;
GetDetails(out userId, out userName);
//new method
GetDetails(out int userIdNew, out string userNameNew);
Console.WriteLine($"{userIdNew} {userNameNew}");
//Use var instead of actual type..
GetDetails(out var userIdVar, out var userNameVar);
//Talk of allowing *, but not implemented.
//GetDetails(out var userIdVar, *);
}
}
}