-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThrow.cs
More file actions
41 lines (40 loc) · 962 Bytes
/
Throw.cs
File metadata and controls
41 lines (40 loc) · 962 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CSharpProgramming
{
/// <summary>
/// Trainee class with Name property
/// </summary>
public class Trainee
{
public string Name { get; set; }
}
internal class Throw
{
public static void Main()
{
Trainee t = null;
try
{
GetName(t);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
/// <summary>
/// Pass an object/instance as a parameter
/// </summary>
/// <param name="trainee"></param>
public static void GetName(Trainee trainee)
{
if (trainee == null)
throw new ArgumentNullException("No trainee name found");
Console.WriteLine(trainee.Name);
}
}
}