<?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%2FMember_Method</id>
		<title>Csharp/CSharp Tutorial/Class/Member Method - История изменений</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%2FMember_Method"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/Member_Method&amp;action=history"/>
		<updated>2026-04-29T21:47:04Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/Member_Method&amp;diff=5711&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/Member_Method&amp;diff=5711&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/Member_Method&amp;diff=5712&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/Member_Method&amp;diff=5712&amp;oldid=prev"/>
				<updated>2010-05-26T12:16:17Z</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;==Define methods==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;Methods are subroutines that manipulate the data defined by the class and provide access to that data.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Other parts of your program will interact with a class through its methods.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;The general form of a method is shown here:&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;access ret-type name(parameter-list) {&lt;br /&gt;
    // body of method&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Define Rectangle class with method to compute the area==&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 Rect { &lt;br /&gt;
  public int width; &lt;br /&gt;
  public int height; &lt;br /&gt;
 &lt;br /&gt;
  public Rect(int w, int h) { &lt;br /&gt;
    width = w; &lt;br /&gt;
    height = h; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  public int area() { &lt;br /&gt;
    return width * height; &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
  &lt;br /&gt;
class UseRect { &lt;br /&gt;
  public static void Main() {   &lt;br /&gt;
    Rect r1 = new Rect(4, 5); &lt;br /&gt;
    Rect r2 = new Rect(7, 9); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Area of r1: &amp;quot; + r1.area()); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Area of r2: &amp;quot; + r2.area()); &lt;br /&gt;
 &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Area of r1: 20&lt;br /&gt;
Area of r2: 63&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Member Functions==&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 Point&lt;br /&gt;
{&lt;br /&gt;
    public Point(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;
    &lt;br /&gt;
    // accessor functions&lt;br /&gt;
    public int GetX() {&lt;br /&gt;
        return(x);&lt;br /&gt;
    }&lt;br /&gt;
    public int GetY() {&lt;br /&gt;
        return(y);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // variables now private&lt;br /&gt;
    int x;&lt;br /&gt;
    int y;&lt;br /&gt;
}&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        Point myPoint = new Point(10, 15);&lt;br /&gt;
        Console.WriteLine(&amp;quot;myPoint.X {0}&amp;quot;, myPoint.GetX());&lt;br /&gt;
        Console.WriteLine(&amp;quot;myPoint.Y {0}&amp;quot;, myPoint.GetY());&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;myPoint.X 10&lt;br /&gt;
myPoint.Y 15&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Nested methods==&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 MainClass&lt;br /&gt;
{&lt;br /&gt;
   static void MethodA(int par1, int par2)&lt;br /&gt;
   {&lt;br /&gt;
      Console.WriteLine(&amp;quot;Enter MethodA: {0}, {1}&amp;quot;, par1, par2);&lt;br /&gt;
      MethodB(11, 18);&lt;br /&gt;
      Console.WriteLine(&amp;quot;Exit MethodA&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
   static void MethodB(int par1, int par2)&lt;br /&gt;
   {&lt;br /&gt;
      Console.WriteLine(&amp;quot;Enter MethodB: {0}, {1}&amp;quot;, par1, par2);&lt;br /&gt;
      Console.WriteLine(&amp;quot;Exit MethodB&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
   static void Main()&lt;br /&gt;
   {&lt;br /&gt;
      MethodA(15, 30);&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Enter MethodA: 15, 30&lt;br /&gt;
Enter MethodB: 11, 18&lt;br /&gt;
Exit MethodB&lt;br /&gt;
Exit MethodA&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Object Class Methods==&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 Product {&lt;br /&gt;
    public string make;&lt;br /&gt;
    public string model;&lt;br /&gt;
    public Product(string make, string model) {&lt;br /&gt;
        this.make = make;&lt;br /&gt;
        this.model = model;&lt;br /&gt;
    }&lt;br /&gt;
    public void Display() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;make = &amp;quot; + make);&lt;br /&gt;
        Console.WriteLine(&amp;quot;model = &amp;quot; + model);&lt;br /&gt;
    }&lt;br /&gt;
    public static Product Copy(Product p) {&lt;br /&gt;
        return (Product)p.MemberwiseClone();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;Creating Product objects&amp;quot;);&lt;br /&gt;
        Product myProduct = new Product(&amp;quot;Toyota&amp;quot;, &amp;quot;MR2&amp;quot;);&lt;br /&gt;
        Product myOtherProduct = new Product(&amp;quot;Porsche&amp;quot;, &amp;quot;Boxter&amp;quot;);&lt;br /&gt;
        myProduct.Display();&lt;br /&gt;
        myOtherProduct.Display();&lt;br /&gt;
        Console.WriteLine(&amp;quot;myProduct.ToString() = &amp;quot; + myProduct.ToString());&lt;br /&gt;
        Console.WriteLine(&amp;quot;myProduct.GetType() = &amp;quot; + myProduct.GetType());&lt;br /&gt;
        Console.WriteLine(&amp;quot;myProduct.GetHashCode() = &amp;quot; + myProduct.GetHashCode());&lt;br /&gt;
        Console.WriteLine(&amp;quot;Product.Equals(myProduct, myOtherProduct) = &amp;quot; + Product.Equals(myProduct, myOtherProduct));&lt;br /&gt;
        Console.WriteLine(&amp;quot;Product.ReferenceEquals(myProduct, myOtherProduct) = &amp;quot; + Product.ReferenceEquals(myProduct, myOtherProduct));&lt;br /&gt;
        myProduct = myOtherProduct;&lt;br /&gt;
        Console.WriteLine(&amp;quot;Product.Equals(myProduct, myOtherProduct) = &amp;quot; + Product.Equals(myProduct, myOtherProduct));&lt;br /&gt;
        Console.WriteLine(&amp;quot;Product.ReferenceEquals(myProduct, myOtherProduct) = &amp;quot; + Product.ReferenceEquals(myProduct, myOtherProduct));&lt;br /&gt;
        Product myOldProduct = Product.Copy(myProduct);&lt;br /&gt;
        myOldProduct.Display();&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Return a value from a member method==&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 area;      &lt;br /&gt;
  public int occupants; &lt;br /&gt;
 &lt;br /&gt;
  // Return the area per person.  &lt;br /&gt;
  public int areaPerPerson() {  &lt;br /&gt;
    return area / occupants; &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();   &lt;br /&gt;
    Building office = new Building(); &lt;br /&gt;
    int areaPP; // area per person &lt;br /&gt;
 &lt;br /&gt;
    house.occupants = 4;  &lt;br /&gt;
    house.area = 2500;  &lt;br /&gt;
 &lt;br /&gt;
    office.occupants = 25;  &lt;br /&gt;
    office.area = 4200;  &lt;br /&gt;
   &lt;br /&gt;
    areaPP = house.areaPerPerson(); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;house has:\n  &amp;quot; + &lt;br /&gt;
                      house.occupants + &amp;quot; occupants\n  &amp;quot; + &lt;br /&gt;
                      house.area + &amp;quot; total area\n  &amp;quot; + &lt;br /&gt;
                      areaPP + &amp;quot; area per person&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
 &lt;br /&gt;
    // obtain area per person for office &lt;br /&gt;
    areaPP = office.areaPerPerson(); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;office has:\n  &amp;quot; + &lt;br /&gt;
                      office.occupants + &amp;quot; occupants\n  &amp;quot; + &lt;br /&gt;
                      office.area + &amp;quot; total area\n  &amp;quot; + &lt;br /&gt;
                      areaPP + &amp;quot; area per person&amp;quot;); &lt;br /&gt;
  }   &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;house has:&lt;br /&gt;
  4 occupants&lt;br /&gt;
  2500 total area&lt;br /&gt;
  625 area per person&lt;br /&gt;
office has:&lt;br /&gt;
  25 occupants&lt;br /&gt;
  4200 total area&lt;br /&gt;
  168 area per person&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>