, , . .
public void MyMethO { int i;
for(i=0; i<10; i++) {
if(i == 5) return; // 5 Console.WriteLine();
}
}
5 for, 5 i .
return, . :
public void MyMethO {
...
If(done) return;
...
If (error) return;
}
: . . - .
, : void : return.
void , , . . 3 Math. Sqrt (), .
. , Math. Sqrt (), , , . #.
return:
return ;
.
, AreaPerPerson (). , . . AreaPerPerson (), , .
// AreaPerPerson().
Using System;
class Building {
public int Floors; //
public int Are-a; //
public int Occupants; //
// , public int AreaPerPerson() {
|
|
return Area / Occupants;
}
}
// , AreaPerPerson(). class BuildingDemo { static void Main() {
Building house = new Building();
Building office = new Building();
int areaPP; //
// house, house.Occupants = 4; house.Area = 2500; house.Floors = 2;
// office, office.Occupants = 25; office.Area = 4200; office.Floors = 3;
// . areaPP = house.AreaPerPerson();
Console.WriteLine(" :\n " +
house.Floors + " \ " + house.Occupants + " \ " + house.Area +
" . , \ " + areaPP + " ");
Console.WriteLine ();
// . areaPP = office.AreaPerPerson();
Console'. WriteLine (" :\n " +
office.Floors + " \ " +
office.Occupants + " \ " +
office.Area +
" . , \ " + areaPP + " ");
}
}