-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstructure.cs
52 lines (38 loc) · 996 Bytes
/
structure.cs
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
using System;
namespace Structs
{
public struct Customer
{
private int _id;
private string _name;
public string Name { get => _name; set => _name = value; }
public int Id { get => _id; set => _id = value; }
public Customer(int Id, string Name)
{
this._id = Id;
this._name = Name;
}
public void PrintDetails()
{
Console.WriteLine("Id = {0} && Name = {1}",this.Id,this.Name);
}
}
class Program
{
static void Main(string[] args)
{
Customer c1 = new Customer(101,"Mark");
c1.PrintDetails();
Customer C2 = new Customer();
C2.Id = 102;
C2.Name = "jOHN";
C2.PrintDetails();
//Object initializer syntax
Customer c3 = new Customer()
{
Id = 103,
Name = "Rob"
};
}
}
}