-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
48 lines (38 loc) · 1.24 KB
/
Copy pathProgram.cs
File metadata and controls
48 lines (38 loc) · 1.24 KB
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
using ping;
using Lists;
using Arraysss;
using GenericClasses;
Arrayss arrays = new Arrayss();
arrays.Arr();
Pinger pinger = new Pinger();
pinger.PerformPing();
Listss myPartsList = new Listss(); // Instantiate the Lists class from the Lists namespace
// Adding parts
myPartsList.AddPart("Engine", 1);
myPartsList.AddPart("Wheel", 2);
myPartsList.AddPart("Brake", 3);
// Displaying parts
myPartsList.DisplayParts();
var intBox = new Box<int>(123);
intBox.DisplayInfo(); // Output: Type: System.Int32, Value: 123
// Create an instance of Box with string
var stringBox = new Box<string>("Hello Generics");
stringBox.DisplayInfo(); // Output: Type: System.String, Value: Hello Generics
// Create an instance of Box with a custom class
var personBox = new Box<Person>(new Person("John", "Doe"));
personBox.DisplayInfo(); // Output: Type: Namespace.Person, Value: Person { FirstName = John, LastName = Doe }
public class Person
{
public string FirstName { get; }
public string LastName { get; }
public Person(string firstName, string lastName)
{
FirstName = firstName;
LastName = lastName;
}
public override string ToString()
{
return $"Person {{ FirstName = {FirstName}, LastName = {LastName} }}";
}
}