-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTypedAndUntypedParamsUse.cs
More file actions
58 lines (57 loc) · 961 Bytes
/
TypedAndUntypedParamsUse.cs
File metadata and controls
58 lines (57 loc) · 961 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
public static void TypedParameters<T>(params T[] incoming)
{
foreach (T param in incoming)
{
// Do your thing
}
}
public static void AnyTypeParameters(params object[] incoming)
{
foreach (object param in incoming)
{
if (param is int)
{
// Its an int
// Do your thing
}
else if (param is float)
{
// Its a float
// Do your thing
}
else if (param is string)
{
// Its a string
// Do your thing
}
else if (param is List<int>)
{
// Its a list of ints
foreach(int subParam in (List<int>)param)
{
// Do your thing
}
}
else if (param is List<float>)
{
// Its a list of floats
foreach (float subParam in (List<float>)param)
{
// Do your thing
}
}
else if (param is List<string>)
{
// Its a list of strings
foreach (string subParam in (List<string>)param)
{
// Do your thing
}
}
else if (param is Vector3)
{
// Its a Vector3
// Do your thing
}
}
}