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

	<entry>
		<id>http://www.nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/Constructor&amp;diff=5699&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/Constructor&amp;diff=5699&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://www.nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/Constructor&amp;diff=5700&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/Constructor&amp;diff=5700&amp;oldid=prev"/>
				<updated>2010-05-26T12:16:14Z</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;==Add a constructor to Triangle.==&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;
  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;
  public Triangle(string s, double w, double h) { &lt;br /&gt;
    width = w;  // init the base class &lt;br /&gt;
    height = h; // init the base class &lt;br /&gt;
 &lt;br /&gt;
    style = s;  // init the derived class &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 MainClass { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    Triangle t1 = new Triangle(&amp;quot;isosceles&amp;quot;, 4.0, 4.0); &lt;br /&gt;
    Triangle t2 = new Triangle(&amp;quot;right&amp;quot;, 8.0, 12.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;
    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;
    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 isosceles&lt;br /&gt;
Width and height are 4 and 4&lt;br /&gt;
Area is 8&lt;br /&gt;
Info for t2:&lt;br /&gt;
Triangle is right&lt;br /&gt;
Width and height are 8 and 12&lt;br /&gt;
Area is 48&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Add a constructor with three parameters==&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 Building {   &lt;br /&gt;
  public int floors;    &lt;br /&gt;
  public int area;      &lt;br /&gt;
  public int occupants; &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  public Building(int f, int a, int o) { &lt;br /&gt;
    floors = f; &lt;br /&gt;
    area = a; &lt;br /&gt;
    occupants = o; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  public int areaPerPerson() {  &lt;br /&gt;
    return area / occupants; &lt;br /&gt;
  }  &lt;br /&gt;
 &lt;br /&gt;
  public int maxOccupant(int minArea) { &lt;br /&gt;
    return area / minArea; &lt;br /&gt;
  } &lt;br /&gt;
}   &lt;br /&gt;
   &lt;br /&gt;
class MainClass {   &lt;br /&gt;
  public static void Main() {   &lt;br /&gt;
    Building house = new Building(2, 2500, 4);   &lt;br /&gt;
    Building office = new Building(3, 4200, 25); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Maximum occupants for house if each has &amp;quot; + &lt;br /&gt;
                      300 + &amp;quot; square feet: &amp;quot; + &lt;br /&gt;
                      house.maxOccupant(300)); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Maximum occupants for office if each has &amp;quot; + &lt;br /&gt;
                      300 + &amp;quot; square feet: &amp;quot; + &lt;br /&gt;
                      office.maxOccupant(300)); &lt;br /&gt;
  }   &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Maximum occupants for house if each has 300 square feet: 8&lt;br /&gt;
Maximum occupants for office if each has 300 square feet: 14&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Add constructor to class==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;A constructor initializes an object when it is created.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;A constructor has the same name as its class&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;A constructor is syntactically similar to a method.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Constructors have no explicit return type.&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The general form of constructor is shown here:&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;access class-name( ) {&lt;br /&gt;
// constructor code&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==An overloaded constructor.==&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 MyClass {  &lt;br /&gt;
  public int x;  &lt;br /&gt;
  &lt;br /&gt;
  public MyClass() { &lt;br /&gt;
    Console.WriteLine(&amp;quot;Inside MyClass().&amp;quot;); &lt;br /&gt;
    x = 0; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  public MyClass(int i) {  &lt;br /&gt;
    Console.WriteLine(&amp;quot;Inside MyClass(int).&amp;quot;); &lt;br /&gt;
    x = i;  &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  public MyClass(double d) { &lt;br /&gt;
    Console.WriteLine(&amp;quot;Inside MyClass(double).&amp;quot;); &lt;br /&gt;
    x = (int) d; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  public MyClass(int i, int j) { &lt;br /&gt;
    Console.WriteLine(&amp;quot;Inside MyClass(int, int).&amp;quot;); &lt;br /&gt;
    x = i * j; &lt;br /&gt;
  }    &lt;br /&gt;
}    &lt;br /&gt;
    &lt;br /&gt;
class MainClass {    &lt;br /&gt;
  public static void Main() {    &lt;br /&gt;
    MyClass t1 = new MyClass();  &lt;br /&gt;
    MyClass t2 = new MyClass(88);  &lt;br /&gt;
    MyClass t3 = new MyClass(17.23);  &lt;br /&gt;
    MyClass t4 = new MyClass(2, 4);  &lt;br /&gt;
  &lt;br /&gt;
    Console.WriteLine(&amp;quot;t1.x: &amp;quot; + t1.x); &lt;br /&gt;
    Console.WriteLine(&amp;quot;t2.x: &amp;quot; + t2.x); &lt;br /&gt;
    Console.WriteLine(&amp;quot;t3.x: &amp;quot; + t3.x); &lt;br /&gt;
    Console.WriteLine(&amp;quot;t4.x: &amp;quot; + t4.x); &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Inside MyClass().&lt;br /&gt;
Inside MyClass(int).&lt;br /&gt;
Inside MyClass(double).&lt;br /&gt;
Inside MyClass(int, int).&lt;br /&gt;
t1.x: 0&lt;br /&gt;
t2.x: 88&lt;br /&gt;
t3.x: 17&lt;br /&gt;
t4.x: 8&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A parameterized constructor==&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 MyClass { &lt;br /&gt;
  public int x; &lt;br /&gt;
 &lt;br /&gt;
  public MyClass(int i) { &lt;br /&gt;
    x = i; &lt;br /&gt;
  }   &lt;br /&gt;
}   &lt;br /&gt;
   &lt;br /&gt;
class MainClass {   &lt;br /&gt;
  public static void Main() {   &lt;br /&gt;
    MyClass t1 = new MyClass(10); &lt;br /&gt;
    MyClass t2 = new MyClass(88); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(t1.x + &amp;quot; &amp;quot; + t2.x); &lt;br /&gt;
  }   &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;10 88&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Class without default constructor==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;public class MyClass&lt;br /&gt;
{&lt;br /&gt;
   public MyClass( int x, int y )&lt;br /&gt;
   {&lt;br /&gt;
      this.x = x;&lt;br /&gt;
      this.y = y;&lt;br /&gt;
   }&lt;br /&gt;
   public int x;&lt;br /&gt;
   public int y;&lt;br /&gt;
}&lt;br /&gt;
public class EntryPoint&lt;br /&gt;
{&lt;br /&gt;
   static void Main()&lt;br /&gt;
   {&lt;br /&gt;
      // We can&amp;quot;t do this!&lt;br /&gt;
      // MyClass objA = new MyClass();&lt;br /&gt;
      MyClass objA = new MyClass( 1, 2 );&lt;br /&gt;
      System.Console.WriteLine( &amp;quot;objA.x = {0}, objA.y = {1}&amp;quot;,&lt;br /&gt;
                                objA.x, objA.y );&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;objA.x = 1, objA.y = 2&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Constuctor hidden==&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;
public class Class1 {&lt;br /&gt;
    public static void Main(string[] args) {&lt;br /&gt;
        SubClass sc1 = new SubClass();&lt;br /&gt;
        SubClass sc2 = new SubClass(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class BaseClass {&lt;br /&gt;
    public BaseClass() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;Constructing BaseClass (default)&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public BaseClass(int i) {&lt;br /&gt;
        Console.WriteLine(&amp;quot;Constructing BaseClass (int)&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class SubClass : BaseClass {&lt;br /&gt;
    public SubClass() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;Constructing SubClass (default)&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public SubClass(int i) {&lt;br /&gt;
        Console.WriteLine(&amp;quot;Constructing SubClass (int)&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Copy constructor==&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 Stack {   &lt;br /&gt;
  char[] stck; // holds the stack  &lt;br /&gt;
  int tos;     // index of the top of the stack  &lt;br /&gt;
   &lt;br /&gt;
  public Stack(int size) {   &lt;br /&gt;
    stck = new char[size];&lt;br /&gt;
    tos = 0;   &lt;br /&gt;
  }   &lt;br /&gt;
  &lt;br /&gt;
  public Stack(Stack ob) {   &lt;br /&gt;
    stck = new char[ob.stck.Length]; &lt;br /&gt;
 &lt;br /&gt;
    for(int i=0; i &amp;lt; ob.tos; i++)  &lt;br /&gt;
      stck[i] = ob.stck[i]; &lt;br /&gt;
 &lt;br /&gt;
    tos = ob.tos; &lt;br /&gt;
  }   &lt;br /&gt;
  &lt;br /&gt;
  public void push(char ch) {   &lt;br /&gt;
    if(tos==stck.Length) {   &lt;br /&gt;
      Console.WriteLine(&amp;quot; -- Stack is full.&amp;quot;);   &lt;br /&gt;
      return;   &lt;br /&gt;
    }   &lt;br /&gt;
       &lt;br /&gt;
    stck[tos] = ch;  &lt;br /&gt;
    tos++;  &lt;br /&gt;
  }   &lt;br /&gt;
   &lt;br /&gt;
  public char pop() {   &lt;br /&gt;
    if(tos==0) {   &lt;br /&gt;
      Console.WriteLine(&amp;quot; -- Stack is empty.&amp;quot;);   &lt;br /&gt;
      return (char) 0;    &lt;br /&gt;
    }   &lt;br /&gt;
     &lt;br /&gt;
    tos--;   &lt;br /&gt;
    return stck[tos];   &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  public bool full() { &lt;br /&gt;
    return tos==stck.Length;    &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  public bool empty() { &lt;br /&gt;
    return tos==0; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  public int capacity() { &lt;br /&gt;
    return stck.Length; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  public int getNum() { &lt;br /&gt;
    return tos; &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
class MainClass {   &lt;br /&gt;
  public static void Main() {   &lt;br /&gt;
    Stack stk1 = new Stack(10);   &lt;br /&gt;
    char ch;   &lt;br /&gt;
    int i;   &lt;br /&gt;
   &lt;br /&gt;
    Console.WriteLine(&amp;quot;Push A through J onto stk1.&amp;quot;); &lt;br /&gt;
    for(i=0; !stk1.full(); i++)   &lt;br /&gt;
      stk1.push((char) (&amp;quot;A&amp;quot; + i));   &lt;br /&gt;
 &lt;br /&gt;
    Stack stk2 = new Stack(stk1); &lt;br /&gt;
  &lt;br /&gt;
    Console.Write(&amp;quot;Contents of stk1: &amp;quot;);   &lt;br /&gt;
    while( !stk1.empty() ) {    &lt;br /&gt;
      ch = stk1.pop();   &lt;br /&gt;
      Console.Write(ch);   &lt;br /&gt;
    }   &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
   &lt;br /&gt;
    Console.Write(&amp;quot;Contents of stk2: &amp;quot;);   &lt;br /&gt;
    while ( !stk2.empty() ) {    &lt;br /&gt;
      ch = stk2.pop();   &lt;br /&gt;
      Console.Write(ch);   &lt;br /&gt;
    }   &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;\n&amp;quot;); &lt;br /&gt;
    &lt;br /&gt;
  }   &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Push A through J onto stk1.&lt;br /&gt;
Contents of stk1: JIHGFEDCBA&lt;br /&gt;
Contents of stk2: JIHGFEDCBA&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Invoke a constructor through this==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The general form is shown here:&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;constructor-name(parameter-list1) : this(parameter-list2) {&lt;br /&gt;
// ... body of constructor, which may be empty&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Multiple Constructor version without duplicating a lot of the constructor code==&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;
public class BankAccount {&lt;br /&gt;
    static int nNextAccountNumber = 1000;&lt;br /&gt;
    int nAccountNumber;&lt;br /&gt;
    double dBalance;&lt;br /&gt;
    public BankAccount() : this(0, 0) { }&lt;br /&gt;
    public BankAccount(double dInitialBalance) :&lt;br /&gt;
        this(0, dInitialBalance) { }&lt;br /&gt;
    public BankAccount(int nInitialAccountNumber,&lt;br /&gt;
                       double dInitialBalance) {&lt;br /&gt;
        if (nInitialAccountNumber &amp;lt;= 0) {&lt;br /&gt;
            nInitialAccountNumber = ++nNextAccountNumber;&lt;br /&gt;
        }&lt;br /&gt;
        nAccountNumber = nInitialAccountNumber;&lt;br /&gt;
        if (dInitialBalance &amp;lt; 0) {&lt;br /&gt;
            dInitialBalance = 0;&lt;br /&gt;
        }&lt;br /&gt;
        dBalance = dInitialBalance;&lt;br /&gt;
    }&lt;br /&gt;
    public string GetString() {&lt;br /&gt;
        return String.Format(&amp;quot;#{0} = {1:N}&amp;quot;,&lt;br /&gt;
                              nAccountNumber, dBalance);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Private copy constructor used when making a copy of this object==&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;
public sealed class Dimensions : ICloneable&lt;br /&gt;
{&lt;br /&gt;
    public Dimensions( long width, long height ) {&lt;br /&gt;
        this.width = width;&lt;br /&gt;
        this.height = height;&lt;br /&gt;
    }&lt;br /&gt;
    private Dimensions( Dimensions other ) {&lt;br /&gt;
        this.width = other.width;&lt;br /&gt;
        this.height = other.height;&lt;br /&gt;
    }&lt;br /&gt;
    public object Clone() {&lt;br /&gt;
        return new Dimensions(this);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    private long width;&lt;br /&gt;
    private long height;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use Constructor to initialize member variables==&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 MyClass&lt;br /&gt;
{&lt;br /&gt;
  public int[] MyIntArray;&lt;br /&gt;
  public int Y;&lt;br /&gt;
  public int ObjectCount = 0;&lt;br /&gt;
  &lt;br /&gt;
  public MyClass()&lt;br /&gt;
  {&lt;br /&gt;
    MyIntArray = new int[10];&lt;br /&gt;
    //Do work necessary during object creation&lt;br /&gt;
  }&lt;br /&gt;
  //Overloads the MyClass allowing you to initialize Y&lt;br /&gt;
  public MyClass(int myY)&lt;br /&gt;
  {&lt;br /&gt;
    Y = myY;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class MainClass{&lt;br /&gt;
  static void Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
    MyClass X = new MyClass();&lt;br /&gt;
    X.ObjectCount++;&lt;br /&gt;
    MyClass YY = new MyClass(10);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>