Shouldly
Search…
ExampleClasses
The classes used in these samples are:
1
using System;
2
3
namespace Simpsons
4
{
5
public abstract class Pet
6
{
7
public abstract string? Name { get; set; }
8
9
public override string? ToString()
10
{
11
return Name;
12
}
13
}
14
15
public class Cat : Pet
16
{
17
public override string? Name { get; set; }
18
}
19
20
public class Dog : Pet
21
{
22
public override string? Name { get; set; }
23
}
24
25
public class Person
26
{
27
public Person()
28
{
29
}
30
31
public Person(string name)
32
{
33
Name = name ?? throw new ArgumentNullException(nameof(name));
34
}
35
36
public string? Name { get; set; }
37
public int Salary { get; set; }
38
39
public override string? ToString()
40
{
41
return Name;
42
}
43
}
44
}
Copied!
Copy link