Skip to content

Commit c0d7355

Browse files
author
ashongwe
committed
adding
1 parent 32807d4 commit c0d7355

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

properties1.cs

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using System;
2+
3+
namespace Properties
4+
{
5+
class Program
6+
{
7+
static void Main(string[] args)
8+
{
9+
Student c1 = new Student();
10+
c1.Id = 101;
11+
c1.Name = "Seefeesaw";
12+
13+
14+
//Console.WriteLine("ID = {0] && nMAE = {1} && pASSmARK = {2}",c1.ID,c1.Name,c1.PasssMark);
15+
Console.WriteLine("Student id = {0} Name = {1}",c1.Id, c1.Name);
16+
17+
}
18+
}
19+
public class Student
20+
{
21+
private int _id;
22+
private string _name;
23+
private int _passsMark;
24+
25+
public int PassMark
26+
{
27+
get
28+
{
29+
return this._passsMark;
30+
}
31+
}
32+
public string Name
33+
{
34+
set
35+
{
36+
if (string.IsNullOrEmpty(value))
37+
{
38+
throw new Exception("Name cannot be null or empty");
39+
}
40+
this._name = value;
41+
}
42+
get
43+
{
44+
return string.IsNullOrEmpty(this._name) ? "No name" : this._name;
45+
}
46+
}
47+
public int Id
48+
{
49+
set
50+
{
51+
if (value <= 0)
52+
{
53+
throw new Exception("Student Id cannot be negative");
54+
}
55+
this._id = value;
56+
}
57+
get
58+
{
59+
return this._id;
60+
}
61+
}
62+
63+
}
64+
}
65+

0 commit comments

Comments
 (0)