-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathStructs_Enums.cs
More file actions
51 lines (46 loc) · 1.03 KB
/
Structs_Enums.cs
File metadata and controls
51 lines (46 loc) · 1.03 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
49
50
51
/*
* Structs and Enums are value types in C#.
*
* Structs: Structs are value types that are typically used to encapsulate small groups of related variables.
* Enums: Enums are value types that are typically used to define a set of named constants.
*/
using System;
namespace Basics
{
class Structs
{
public struct Point
{
public int x;
public int y;
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
}
public void Display()
{
Point p1 = new Point(10, 15);
Console.WriteLine($"p1.x = {p1.x}, p1.y = {p1.y}");
}
}
class Enums
{
public enum Days
{
Sunday,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday
}
public void Display()
{
Days today = Days.Monday;
Console.WriteLine(today);
}
}
}