.


:




:

































 

 

 

 


IComparable , .




int CompareTo(object obj) /

, obj. , obj, ; , , obj, .

IComparable .

public interface IComparable<T>

. CompareTo () , .

int CompareTo( other)

, CompareTo (), . , IComparable<T> . #, IComparable.

IEquatable<T>

IEquatable<T> , . , Equals (), .

bool Equals( other)

true, other, false.

IEquatable<T> .NET Framework, String. IEquatable<T> Equals (Object) GetHashCode (), Object.

IConvertible

IConvertible , String DateTime. . , , .

ICloneable

ICloneable, . ICloneable , Clone (), .

Object Clone()

, . , : . , . , , . , , . , , , , , . , Clone () . MemberwiseClone (), Obj ect.

, ICloneable. Test, X. Test Clone () .

// ICloneable.

Using System;

class X {

Public int a;

public X(int x) { a = x; }

}

class Test: ICloneable {

Public X ; public int b;

public Test (int x, int y) { = new X(x); b = y;

}

public void Show(string name) {

Console.Write(" " + name + ": ");

Console.WriteLine("o.a: {0}, b: {1}", o.a, b);

}

// , public object Clone() {

Test temp = new Test(o.a, b); return temp;

}

}

class CloneDemo {

static void Main() {

Test obi = new Test(10, 20);

obi.Show("obi");

Console.WriteLine(" ob2 obi.");

Test ob2 = (Test) obi.Clone ();

ob2.Show("ob2");

Console.WriteLine(" obi.. 99, " +

" obl.b 88.");

obi..a = 99; obl.b = 88;

obi.Show("obi"); ob2.Show("ob2");

}

}

, .

: .: 10, : 20 2 .

2: .: 10, : 20





:


: 2016-12-03; !; : 480 |


:

:

: , .
==> ...

1336 - | 943 -


© 2015-2024 lektsii.org - -

: 0.011 .