.


:




:

































 

 

 

 


.




// .

using System;

class MyClass { public int x;

public MyClass() {

x = 10;

}

}

class ConsDemo {

static void Main() {

MyClass tl = new MyClass();

MyClass t2 = new MyClass();

Console.WriteLine(tl,x + " " + t2.x);

}

}

MyClass .

public MyClassO {

X = 10;

}

, public. , , . MyClass 10. new . , :

MyClass tl = new MyClassO;

MyClass () tl, tl. 10. t2. t2. 10. , .

10 10

. , , . , . . MyClass.

// .

Using System;

class MyClass { public int x;

public MyClass(int i) { x = i;

}

}

class ParmConsDemo { static void Main() {

MyClass tl = new MyClass(10);

MyClass t2 = new MyClass(88);

Console.WriteLine(tl.x + " " + t2.x);

}

}

.

10 88

MyClass () i, . :

MyClass tl = new MyClass(10);

i , .

Building

Building , , Floors, Area Occupants . , Building.

// Building.

Using System;

class Building {

public int Floors; //

public int Area; //

public int Occupants; //

// Building, public Building(int f, int a, int o) {

Floors = f;

Area = a;

Occupants = o;

} \

// , public int AreaPerPerson() {

return Area / Occupants;

}

// , ,

// . ^ public int MaxOccupant(int minArea) { return Area / minArea;

}

}

// Building, class BuildingDemo { static void Main() {

Building house = new Building(2, 2500, 4);

Building office = new Building(3, 4200, 25);

Console.WriteLine(" , \" +

" " +

300,+ " . : " + house.MaxOccupant(300));

Console.WriteLine(" " +

" , \" +

" " +

300 + " . : " + office.MaxOccupant(300));

}

}

, .

, house office, Building () , . ,

Building house = new Building(2, 2500, 4);

Building () 2, 2500 4 . , Floors, Area Occupants house 2, 2500 4 .

new

, , new, . new :

new _ (_)

_ , . _ . , new , C# . , new , .

, , new - . ( 13). , , , , , , , .

new

: new , int float? C# . . , new . , , .

, int char, , . , . .





:


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


:

:

, - , ; , - .
==> ...

1198 - | 1232 -


© 2015-2024 lektsii.org - -

: 0.016 .