-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmploye1.cs
115 lines (97 loc) · 3.06 KB
/
Employe1.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1.DemoA.NewFolder1
{
class Employe1
{
static void Main(string[] args)
{
List<int> a1 = new List<int>();
a1.Add(10);
a1.Add(40);
a1.Add(70);
a1.Count();
a1.Insert(1,20);
a1.Add(40);
a1[0] = 100;
a1.Add(600);
// a1.Remove(10);
foreach (var data in a1)
{
Console.WriteLine(data);
}
Console.ReadLine();
Console.WriteLine(a1.Contains(600));
Console.WriteLine(a1.Count);
Console.ReadLine();
foreach(var data in a1)
{
Console.WriteLine(data);
}
a1.Reverse();
a1.Sort();
foreach (var data in a1)
{
Console.WriteLine(data);
}
Console.ReadLine();
}
}
class Emp:IComparable<Emp>
{
int empId;
string empName;
float empSalary;
public Emp(int empId, string empName, float empSalary)
{
this.EmpId = empId;
this.EmpName = empName;
this.EmpSalary = empSalary;
}
public int EmpId { get => empId; set => empId = value; }
public string EmpName { get => empName; set => empName = value; }
public float EmpSalary { get => empSalary; set => empSalary = value; }
public override string ToString()
{
return $"EmpID {empId},EmpName{empName},EmpSalary{empSalary}";
}
static void Main(string[] args)
{
Console.WriteLine("Geeta".CompareTo("Manjiri"));
List<Emp> slistemp = new List<Emp>();
slistemp.Add(new Emp(1, "Vinaya", 5000f));
slistemp.Add(new Emp(2, "vini", 8000f));
slistemp.Add(new Emp(1, "Manisha", 4000f));
slistemp.Add(new Emp(1, "Rajvi", 9000f));
slistemp.Add(new Emp(1, "Geeta", 10000f));
slistemp.Add(new Emp(1, "Babitaa", 3000f));
slistemp.Add(new Emp(1, "Manjiri", 2000f));
foreach(var employe in slistemp)
{
Console.WriteLine(employe);
}Console.WriteLine();
slistemp.Reverse();
slistemp.Sort();
foreach(var emp in slistemp)
{
Console.WriteLine(emp);
}Console.ReadLine();
}
public int CompareTo(Emp other)
{
//throw new NotImplementedException();
Console.WriteLine("in compare method");
Console.WriteLine("this ---->" + this);
Console.WriteLine("other----->" + other);
if (this.empSalary < other.empSalary)
return -1;
else if (this.empSalary > other.empSalary)
return 1;
else
return 0;
}
}
}