.


:




:

































 

 

 

 


Monster.SortBy !!!




Array.Sort(mas, new Monster.SortBy());

foreach (Monster x in mas)

x.Passport();

Console.WriteLine(" ");

Array.Sort(mas, new Monster.SortBy());

foreach (Monster x in mas)

x.Passport();

Console.ReadLine(); } }}

( ICloneable)

- . . , . , MemberwiseClone(), object. , , , . . , , , , , .. , .

, , ICloneable Clone().

Monster MemberwiseClone() ICloneable. MemberwiseClone() , object protected.

using System;

using System.Collections;

using System.Linq;

using System.Text;

namespace ConsoleApplication1

{

class Monster:ICloneable

{

public Monster(int , int , string )

{

this. = ;

this. = ;

this. = ;

}

public Monster ShallowClone()

{

return (Monster)this.MemberwiseClone();

}

public object Clone()

{

return new Monster(this., this., "-!" + this.);

}

public int

{

get { return ; }

set

{

if (value > 0) = value;

else = 0;

}

}

public void Passport()

{

Console.WriteLine(" {0} = {1} = {2}", , , );

}

string ;

int , ;

}

class Program

{

static void Main(string[] args)

{ Monster =new Monster (100,100,"");

Monster X = ;

//2 ShallowClone() Clone()

Monster Y = .ShallowClone();

Monster Z = (Monster).Clone();

.Passport();

X.Passport();

Y.Passport();

Z.Passport();

Console.ReadLine(); } }}

 

X . . , , . Y Z, , .

 





:


: 2015-05-05; !; : 427 |


:

:

: , , , , .
==> ...

1439 - | 1315 -


© 2015-2024 lektsii.org - -

: 0.009 .