עליך להתחבר בכדי להוריד קבצים מהאתר
על מנת להבטיח שמשאבינו לא ינוצלו לרעה.
1 : public class Point
2 : {
3 : private int x;
4 : private int y;
5 : public void SetX(int x)
6 : {
7 : this.x = x;
8 : }
9 : public void SetY(int y)
10 : {
11 : this.y = y;
12 : }
13 : public void Print()
14 : {
15 : Console.WriteLine("X = {0}", x);
16 : Console.WriteLine("Y = {0}", y);
17 : }
18 : }
1 : public class Point
2 : {
3 : private int x;
4 : private int y;
5 : public Point()
6 : {
7 :
8 : }
9 : public void SetX(int x)
10 : {
11 : this.x = x;
12 : }
13 : public void SetY(int y)
14 : {
15 : this.y = y;
16 : }
17 : public void Print()
18 : {
19 : Console.WriteLine("X = {0}", x);
20 : Console.WriteLine("Y = {0}", y);
21 : }
22 : }
public Point() { int x = 1; int y = 1; } |
1 : class Point
2 : {
3 : private int x;
4 : private int y;
5 : public Point()
6 : {
7 : x = 1;
8 : y = 1;
9 : }
10 : public Point(int x, int y)
11 : {
12 : this.x = x;
13 : this.y = y;
14 : }
15 : public void SetX(int x)
16 : {
17 : this.x = x;
18 : }
19 : public void SetY(int y)
20 : {
21 : this.y = y;
22 : }
23 : public void Print()
24 : {
25 : Console.WriteLine("X = {0}", x);
26 : Console.WriteLine("Y = {0}", y);
27 : }
28 : }
class ClassName
{ public ClassName():this(Type1 var1)
{ . . .
}
public ClassName(Type1 var1) { . . .
}
}
|
1 : class Person
2 : {
3 : private string LastName;
4 : private string FirstName;
5 : private float SalaryPerHour;
6 : private float WorkingHours;
7 : public Person()
8 : : this("--------", "--------")
9 : {
10 : Console.WriteLine("First Ctor");
11 : }
12 : public Person(string ln, string fn)
13 : : this(ln, fn, -1, -1)
14 : {
15 : Console.WriteLine("Second Ctor");
16 : LastName = ln;
17 : FirstName = fn;
18 : }
19 : public Person(string ln, string fn, float sal, float hours)
20 : {
21 : Console.WriteLine("Third Ctor");
22 : LastName = ln;
23 : FirstName = fn;
24 : SalaryPerHour = sal;
25 : WorkingHours = hours;
26 : }
27 : . . .
28 : }
1 : class Program
2 : {
3 : static void Main(string[] args)
4 : {
5 : Person e1 = new Person();
6 : Person e2 = new Person("Moshe", "Stamshem");
7 : e2.Print();
8 :
9 : }
10 : }