.


:




:

































 

 

 

 


, .




C# : . , . , . .

// // .

Using System;

class X {

Public int a;

public X(int i) { a = i;

}

}

class Y: X { public int b;

public Y(int i, int j): base(j) { b = i;

}

}

class BaseRef {

static void Main() {

X x = new X(10);

X x2;

Y = new Y (5, 6);

x2 = x; // , Console.WriteLine ("2.: " + 2.);

2 = ; // , Y X Console.WriteLine ("2.: " + 2.);

// X X 2. = 19; // // 2. = 27; // , b X }

}

Y X. :

2 = ; // , Y X

. ( 2 X) , .. , .

, , , . , , , . 2 b Y, . , , -

. .

-, . , , .

, . , , . . , . TwoDShape Triangle. , .

// // .

Using System;

class TwoDShape { double pri_width; double pri_height;

// , public TwoDShape() {

Width = Height = 0.0;

}

// TwoDShape. public TwoDShape(double w, double h) {

Width = w;

Height = h;

}

// , public TwoDShape(double ) {

Width = Height = x;

}

// TwoDShape. public TwoDShape(TwoDShape ob) {

Width = ob.Width;

Height = ob.Height;

}

// , public double Width {

get { return pri_width; }

set { pri_width = value < 0? -value: value; }

}

get { return pri_height; }

set { pri_height = value < 0? -value: value; }

}

public void ShowDim() {

Console.WriteLine(" " +

Width + " " + Height);

}

}

// , TwoDShape. class Triangle: TwoDShape { string Style;

// , , public Triangle() {

Style = "null";

}

// Triangle.

public Triangle(string s, double w, double h): base(w, h) { Style = s;

}

// , public Triangle(double x): base (x) {

Style = "";

}

// Triangle, public Triangle(Triangle ob): base (ob) {

Style = ob.Style;

}

// , public double Area() {

return Width * Height / 2;

}

// , public void ShowStyle() {

Console.WriteLine(" " + Style);

}

}

class Shapes7 {

static void Ma^n() {

Triangle tl = new Triangle("", 8.0, 12.0);

// tl.

Triangle t2 = new Triangle ('t*L);

Console.WriteLine(" tl: "); tl.ShowStyle();

Tl.ShowDim();

Console.WriteLine (" " + tl.AreaO);

Console.WriteLine ();

Console.WriteLine(" t2: "); t2.ShowStyle(); t2.ShowDim();

Console.WriteLine(" " + t2.Area());

}

}

t2 tin . ' .

tl:





:


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


:

:

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

1691 - | 1701 -


© 2015-2024 lektsii.org - -

: 0.012 .