<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FClass%2FClass_hierarchy</id>
		<title>Csharp/CSharp Tutorial/Class/Class hierarchy - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FClass%2FClass_hierarchy"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/Class_hierarchy&amp;action=history"/>
		<updated>2026-04-29T18:29:27Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/Class_hierarchy&amp;diff=5643&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/Class_hierarchy&amp;diff=5643&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:53Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/Class_hierarchy&amp;diff=5644&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/Class_hierarchy&amp;diff=5644&amp;oldid=prev"/>
				<updated>2010-05-26T12:16:05Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==A multilevel hierarchy.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System; &lt;br /&gt;
 &lt;br /&gt;
class Shape { &lt;br /&gt;
  double pri_width;  // private &lt;br /&gt;
  double pri_height; // private  &lt;br /&gt;
 &lt;br /&gt;
  // Default constructor. &lt;br /&gt;
  public Shape() { &lt;br /&gt;
    width = height = 0.0; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // Constructor for Shape. &lt;br /&gt;
  public Shape(double w, double h) { &lt;br /&gt;
    width = w; &lt;br /&gt;
    height = h; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // Construct object with equal width and height. &lt;br /&gt;
  public Shape(double x) { &lt;br /&gt;
    width = height = x; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // Properties for width and height. &lt;br /&gt;
  public double width { &lt;br /&gt;
     get { return pri_width; } &lt;br /&gt;
     set { pri_width = value; } &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  public double height { &lt;br /&gt;
     get { return pri_height; } &lt;br /&gt;
     set { pri_height = value; } &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  public void showDim() { &lt;br /&gt;
    Console.WriteLine(&amp;quot;Width and height are &amp;quot; + &lt;br /&gt;
                       width + &amp;quot; and &amp;quot; + height); &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
class Triangle : Shape { &lt;br /&gt;
  string style; // private &lt;br /&gt;
   &lt;br /&gt;
  /* A default constructor. This invokes the default &lt;br /&gt;
     constructor of Shape. */ &lt;br /&gt;
  public Triangle() { &lt;br /&gt;
    style = &amp;quot;null&amp;quot;; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // Constructor &lt;br /&gt;
  public Triangle(string s, double w, double h) : base(w, h) { &lt;br /&gt;
    style = s;  &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // Construct an isosceles triangle. &lt;br /&gt;
  public Triangle(double x) : base(x) { &lt;br /&gt;
    style = &amp;quot;isosceles&amp;quot;;  &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // Return area of triangle. &lt;br /&gt;
  public double area() { &lt;br /&gt;
    return width * height / 2; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // Display a triangle&amp;quot;s style. &lt;br /&gt;
  public void showStyle() { &lt;br /&gt;
    Console.WriteLine(&amp;quot;Triangle is &amp;quot; + style); &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
class ColorTriangle : Triangle { &lt;br /&gt;
  string color; &lt;br /&gt;
 &lt;br /&gt;
  public ColorTriangle(string c, string s, &lt;br /&gt;
                       double w, double h) : base(s, w, h) { &lt;br /&gt;
    color = c; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // Display the color. &lt;br /&gt;
  public void showColor() { &lt;br /&gt;
    Console.WriteLine(&amp;quot;Color is &amp;quot; + color); &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
class MainClass { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    ColorTriangle t1 = new ColorTriangle(&amp;quot;Blue&amp;quot;, &amp;quot;right&amp;quot;, 8.0, 12.0); &lt;br /&gt;
    ColorTriangle t2 = new ColorTriangle(&amp;quot;Red&amp;quot;, &amp;quot;isosceles&amp;quot;, 2.0, 2.0); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Info for t1: &amp;quot;); &lt;br /&gt;
    t1.showStyle(); &lt;br /&gt;
    t1.showDim(); &lt;br /&gt;
    t1.showColor(); &lt;br /&gt;
    Console.WriteLine(&amp;quot;Area is &amp;quot; + t1.area()); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Info for t2: &amp;quot;); &lt;br /&gt;
    t2.showStyle(); &lt;br /&gt;
    t2.showDim(); &lt;br /&gt;
    t2.showColor(); &lt;br /&gt;
    Console.WriteLine(&amp;quot;Area is &amp;quot; + t2.area()); &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Info for t1:&lt;br /&gt;
Triangle is right&lt;br /&gt;
Width and height are 8 and 12&lt;br /&gt;
Color is Blue&lt;br /&gt;
Area is 48&lt;br /&gt;
Info for t2:&lt;br /&gt;
Triangle is isosceles&lt;br /&gt;
Width and height are 2 and 2&lt;br /&gt;
Color is Red&lt;br /&gt;
Area is 2&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A simple class hierarchy.==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;A class that is inherited is called a base class.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;The inheriting class is called a derived class.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;A derived class is a specialized version of a base class.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;A derived class has all of the variables, methods, properties, operators, and indexers from the base class&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;A derived class adds its own unique elements.&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The general form of a class declaration that inherits a base class:&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;class derived-class-name : base-class-name {&lt;br /&gt;
    // body of class&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Demonstrate when constructors are called.==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The general form of calling base constructor:&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;derived-constructor(parameter-list) : base(arg-list) {&lt;br /&gt;
    // body of constructor&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Inherited Implementation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
&lt;br /&gt;
interface Interface1 { &lt;br /&gt;
     void PrintOut(string s); &lt;br /&gt;
}&lt;br /&gt;
class BaseClass &lt;br /&gt;
{&lt;br /&gt;
   public void PrintOut(string s)      &lt;br /&gt;
   {&lt;br /&gt;
      Console.WriteLine(&amp;quot;Calling through: {0}&amp;quot;, s);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
class Derived : BaseClass, Interface1     &lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
   static void Main()&lt;br /&gt;
   {&lt;br /&gt;
      Derived d = new Derived();       &lt;br /&gt;
      d.PrintOut(&amp;quot;object.&amp;quot;);           &lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Calling through: object.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Simple Inheritance==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
class Employee&lt;br /&gt;
{&lt;br /&gt;
    public Employee(string name, float billingRate)&lt;br /&gt;
    {&lt;br /&gt;
        this.name = name;&lt;br /&gt;
        this.billingRate = billingRate;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public float CalculateCharge(float hours)&lt;br /&gt;
    {&lt;br /&gt;
        return(hours * billingRate);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public string TypeName()&lt;br /&gt;
    {&lt;br /&gt;
        return(&amp;quot;Employee&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    private string name;&lt;br /&gt;
    protected float billingRate;&lt;br /&gt;
}&lt;br /&gt;
class Manager: Employee&lt;br /&gt;
{&lt;br /&gt;
    public Manager(string name, float billingRate) : base(name, billingRate)&lt;br /&gt;
    {&lt;br /&gt;
    }&lt;br /&gt;
    public new float CalculateCharge(float hours)&lt;br /&gt;
    {&lt;br /&gt;
        if (hours &amp;lt; 1.0F)&lt;br /&gt;
        hours = 1.0F;&lt;br /&gt;
        return(hours * billingRate);&lt;br /&gt;
    }&lt;br /&gt;
    public new string TypeName()&lt;br /&gt;
    {&lt;br /&gt;
        return(&amp;quot;Civil Employee&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Test&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        Employee    e = new Employee(&amp;quot;A&amp;quot;, 15.50F);&lt;br /&gt;
        Manager    c = new Manager(&amp;quot;B&amp;quot;, 40F);&lt;br /&gt;
        &lt;br /&gt;
        Console.WriteLine(&amp;quot;{0} charge = {1}&amp;quot;,&lt;br /&gt;
        e.TypeName(),&lt;br /&gt;
        e.CalculateCharge(2F));&lt;br /&gt;
        Console.WriteLine(&amp;quot;{0} charge = {1}&amp;quot;,&lt;br /&gt;
        c.TypeName(),&lt;br /&gt;
        c.CalculateCharge(0.75F));&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Employee charge = 31&lt;br /&gt;
Civil Employee charge = 40&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>