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

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/Method_Parameter&amp;diff=5651&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/Method_Parameter&amp;diff=5651&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/Method_Parameter&amp;diff=5652&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/Method_Parameter&amp;diff=5652&amp;oldid=prev"/>
				<updated>2010-05-26T12:16:07Z</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 member function with two arguments==&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 ChkNum {  &lt;br /&gt;
  public int sum(int a, int b) { &lt;br /&gt;
    int max; &lt;br /&gt;
    max = a &amp;lt; b ? a : b; &lt;br /&gt;
 &lt;br /&gt;
    return max; &lt;br /&gt;
  } &lt;br /&gt;
}  &lt;br /&gt;
  &lt;br /&gt;
class MainClass {  &lt;br /&gt;
  public static void Main() {  &lt;br /&gt;
    ChkNum ob = new ChkNum(); &lt;br /&gt;
    int a, b; &lt;br /&gt;
 &lt;br /&gt;
    a = 7; &lt;br /&gt;
    b = 8; &lt;br /&gt;
    Console.WriteLine(ob.sum(a, b)); &lt;br /&gt;
 &lt;br /&gt;
    a = 100; &lt;br /&gt;
    b = 8; &lt;br /&gt;
    Console.WriteLine(ob.sum(a, b)); &lt;br /&gt;
 &lt;br /&gt;
    a = 100; &lt;br /&gt;
    b = 75; &lt;br /&gt;
    Console.WriteLine(ob.sum(a, b)); &lt;br /&gt;
 &lt;br /&gt;
  }  &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;7&lt;br /&gt;
8&lt;br /&gt;
75&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==C# Parameter Modifiers==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;Parameter Modifier                           Meaning in Life&lt;br /&gt;
(none)                                       Assumed to be passed by value.&lt;br /&gt;
out                                          Output parameters are assigned. &lt;br /&gt;
params                                       send in a variable number of arguments as a single logical parameter. &lt;br /&gt;
ref                                          The value is initially assigned by the caller, and may be optionally reassigned by the called method.&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Creating a method with a reference argument.==&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;
    static void Main() {&lt;br /&gt;
        int x = 10;&lt;br /&gt;
        Console.WriteLine(&amp;quot;Before calling non-ref function, x = {0}&amp;quot;, x);&lt;br /&gt;
        NonRefFunction(x);&lt;br /&gt;
        Console.WriteLine(&amp;quot;After calling non-ref function, x = {0}&amp;quot;, x);&lt;br /&gt;
        RefFunction(ref x);&lt;br /&gt;
        Console.WriteLine(&amp;quot;After calling ref function, x = {0}&amp;quot;, x);&lt;br /&gt;
    }&lt;br /&gt;
    static void NonRefFunction(int x) {&lt;br /&gt;
        Console.WriteLine(&amp;quot;Top of NonRefFunction. X = {0}&amp;quot;, x);&lt;br /&gt;
        x = x + 10;&lt;br /&gt;
        Console.WriteLine(&amp;quot;Bottom of NonRefFunction. X = {0}&amp;quot;, x);&lt;br /&gt;
    }&lt;br /&gt;
    static void RefFunction(ref int x) {&lt;br /&gt;
        Console.WriteLine(&amp;quot;Top of RefFunction. X = {0}&amp;quot;, x);&lt;br /&gt;
        x = x + 10;&lt;br /&gt;
        Console.WriteLine(&amp;quot;Bottom of RefFunction. X = {0}&amp;quot;, x);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==How Arguments Are Passed==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Call-by-value:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;Copy the value of an argument into the formal parameter.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Change made to the parameter have no effect on the argument used in the call .&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Call-by-reference.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;A reference to an argument is passed to the parameter.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Change made to the parameter will affect the argument used to call the subroutine.&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;When you pass a value type, such as int or double, to a method, it is passed by value.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;An object is passed by reference&amp;lt;/p&amp;gt;&lt;br /&gt;
7.6.Method Parameter&lt;br /&gt;
7.6.1.&lt;br /&gt;
How Arguments Are Passed&lt;br /&gt;
7.6.2.&lt;br /&gt;
&amp;lt;A href=&amp;quot;/Tutorial/CSharp/0140__Class/Parametermodifiers.htm&amp;quot;&amp;gt;Parameter modifiers&amp;lt;/a&amp;gt;&lt;br /&gt;
7.6.3.&lt;br /&gt;
&amp;lt;A href=&amp;quot;/Tutorial/CSharp/0140__Class/Passintvaluetoafunction.htm&amp;quot;&amp;gt;Pass int value to a function&amp;lt;/a&amp;gt;&lt;br /&gt;
7.6.4.&lt;br /&gt;
&amp;lt;A href=&amp;quot;/Tutorial/CSharp/0140__Class/Useaparameterinamemberfunction.htm&amp;quot;&amp;gt;Use a parameter in a member function&amp;lt;/a&amp;gt;&lt;br /&gt;
7.6.5.&lt;br /&gt;
&amp;lt;A href=&amp;quot;/Tutorial/CSharp/0140__Class/Amemberfunctionwithtwoarguments.htm&amp;quot;&amp;gt;A member function with two arguments&amp;lt;/a&amp;gt;&lt;br /&gt;
7.6.6.&lt;br /&gt;
&amp;lt;A href=&amp;quot;/Tutorial/CSharp/0140__Class/Passintwithoutoutandref.htm&amp;quot;&amp;gt;Pass int without &amp;quot;out&amp;quot; and &amp;quot;ref&amp;quot;&amp;lt;/a&amp;gt;&lt;br /&gt;
7.6.7.&lt;br /&gt;
&amp;lt;A href=&amp;quot;/Tutorial/CSharp/0140__Class/Passintegerbyref.htm&amp;quot;&amp;gt;Pass integer by ref&amp;lt;/a&amp;gt;&lt;br /&gt;
7.6.8.&lt;br /&gt;
&amp;lt;A href=&amp;quot;/Tutorial/CSharp/0140__Class/refparameters.htm&amp;quot;&amp;gt;ref parameters&amp;lt;/a&amp;gt;&lt;br /&gt;
7.6.9.&lt;br /&gt;
&amp;lt;A href=&amp;quot;/Tutorial/CSharp/0140__Class/Passintegervaluebyvalue.htm&amp;quot;&amp;gt;Pass integer value by value&amp;lt;/a&amp;gt;&lt;br /&gt;
7.6.10.&lt;br /&gt;
&amp;lt;A href=&amp;quot;/Tutorial/CSharp/0140__Class/paramsintargs.htm&amp;quot;&amp;gt;params int[] args&amp;lt;/a&amp;gt;&lt;br /&gt;
7.6.11.&lt;br /&gt;
&amp;lt;A href=&amp;quot;/Tutorial/CSharp/0140__Class/Useoutforinttype.htm&amp;quot;&amp;gt;Use out for int type&amp;lt;/a&amp;gt;&lt;br /&gt;
7.6.12.&lt;br /&gt;
&amp;lt;A href=&amp;quot;/Tutorial/CSharp/0140__Class/Creatingamethodwithareferenceargument.htm&amp;quot;&amp;gt;Creating a method with a reference argument.&amp;lt;/a&amp;gt;&lt;br /&gt;
7.6.13.&lt;br /&gt;
&amp;lt;A href=&amp;quot;/Tutorial/CSharp/0140__Class/VariableargumentstoamethodinC.htm&amp;quot;&amp;gt;Variable arguments to a method in C#.&amp;lt;/a&amp;gt;&lt;br /&gt;
7.6.14.&lt;br /&gt;
&amp;lt;A href=&amp;quot;/Tutorial/CSharp/0140__Class/Methodparameterhidestheclassmemberfield.htm&amp;quot;&amp;gt;Method parameter hides the class member field&amp;lt;/a&amp;gt;&lt;br /&gt;
7.6.15.&lt;br /&gt;
&amp;lt;A href=&amp;quot;/Tutorial/CSharp/0140__Class/CParameterModifiers.htm&amp;quot;&amp;gt;C# Parameter Modifiers&amp;lt;/a&amp;gt;&lt;br /&gt;
7.6.16.&lt;br /&gt;
&amp;lt;A href=&amp;quot;/Tutorial/CSharp/0140__Class/useofoutervariableinanonymousmethod.htm&amp;quot;&amp;gt;use of &amp;quot;outer variable&amp;quot; in anonymous method&amp;lt;/a&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Method parameter hides the class member field==&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 Product {&lt;br /&gt;
    public int yearBuilt;&lt;br /&gt;
    public double maximumSpeed;&lt;br /&gt;
    public int Age(int currentYear) {&lt;br /&gt;
        int maximumSpeed = 100;  // hides the field&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;In Age(): maximumSpeed = &amp;quot; + maximumSpeed);&lt;br /&gt;
        int age = currentYear - yearBuilt;&lt;br /&gt;
        return age;&lt;br /&gt;
    }&lt;br /&gt;
    public double Distance(double initialSpeed, double time) {&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;In Distance(): maximumSpeed = &amp;quot; + maximumSpeed);&lt;br /&gt;
        return (initialSpeed + maximumSpeed) / 2 * time;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class MainClass{&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        Product redPorsche = new Product();&lt;br /&gt;
        redPorsche.yearBuilt = 2000;&lt;br /&gt;
        redPorsche.maximumSpeed = 150;&lt;br /&gt;
        int age = redPorsche.Age(2001);&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;redPorsche is &amp;quot; + age + &amp;quot; year old.&amp;quot;);&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;redPorsche travels &amp;quot; + redPorsche.Distance(31, .25) + &amp;quot; miles.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Parameter modifiers==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;Parameter modifier      Passed by              Variable must be definitely assigned&lt;br /&gt;
None                  Value                  Going in&lt;br /&gt;
ref                     Reference              Going in&lt;br /&gt;
out                     Reference              Going out&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==params int[] args==&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 Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
    MyMethod(5,5,5,5);&lt;br /&gt;
   &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  static public void MyMethod(params int[] args)&lt;br /&gt;
  {&lt;br /&gt;
    for (int I = 0; I &amp;lt; args.Length; I++)&lt;br /&gt;
      Console.WriteLine(args[I]);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;5&lt;br /&gt;
5&lt;br /&gt;
5&lt;br /&gt;
5&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pass integer by ref==&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 Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
      int MyInt = 5;&lt;br /&gt;
    MyMethodRef(ref MyInt);&lt;br /&gt;
   &lt;br /&gt;
        Console.WriteLine(MyInt);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  static public int MyMethodRef(ref int myInt)&lt;br /&gt;
  {&lt;br /&gt;
    myInt = myInt + myInt;&lt;br /&gt;
    return myInt;&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;10&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pass integer value by value==&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 Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
      int MyInt = 5;&lt;br /&gt;
    MyMethod( MyInt);&lt;br /&gt;
   &lt;br /&gt;
        Console.WriteLine(MyInt);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  static public int MyMethod( int myInt)&lt;br /&gt;
  {&lt;br /&gt;
    myInt = myInt + myInt;&lt;br /&gt;
    return myInt;&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;5&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pass int value to a function==&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;
   public static void Main() {&lt;br /&gt;
      int SomeInt = 6;&lt;br /&gt;
      &lt;br /&gt;
      int s = Sum(5, SomeInt);&lt;br /&gt;
      &lt;br /&gt;
      Console.WriteLine(s);        &lt;br /&gt;
   }&lt;br /&gt;
   public static int Sum(int x, int y)               // Declare the method.&lt;br /&gt;
   {&lt;br /&gt;
      return x + y;                                  // Return the sum.&lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;11&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pass int without &amp;quot;out&amp;quot; and &amp;quot;ref&amp;quot;==&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 Val = 20;&lt;br /&gt;
}&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
   static void MyMethod(MyClass myObject, int intValue)&lt;br /&gt;
   {&lt;br /&gt;
      myObject.Val = myObject.Val + 5;&lt;br /&gt;
      intValue = intValue + 5;        &lt;br /&gt;
   }&lt;br /&gt;
   static void Main()&lt;br /&gt;
   {&lt;br /&gt;
      MyClass myObject = new MyClass();&lt;br /&gt;
      int intValue = 10;&lt;br /&gt;
      Console.WriteLine(&amp;quot;Before -- myObject.Val: {0}, intValue: {1}&amp;quot;, myObject.Val, intValue);&lt;br /&gt;
      MyMethod(myObject, intValue);&lt;br /&gt;
      Console.WriteLine(&amp;quot;After  -- myObject.Val: {0}, intValue: {1}&amp;quot;, myObject.Val, intValue);&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Before -- myObject.Val: 20, intValue: 10&lt;br /&gt;
After  -- myObject.Val: 25, intValue: 10&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==ref 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;
class Color {&lt;br /&gt;
    public Color() {&lt;br /&gt;
        this.red = 0;&lt;br /&gt;
        this.green = 127;&lt;br /&gt;
        this.blue = 255;&lt;br /&gt;
    }&lt;br /&gt;
    protected int red;&lt;br /&gt;
    protected int green;&lt;br /&gt;
    protected int blue;&lt;br /&gt;
    public void GetRGB(&lt;br /&gt;
        ref int red, ref int green, ref int blue) {&lt;br /&gt;
        red = this.red;&lt;br /&gt;
        green = this.green;&lt;br /&gt;
        blue = this.blue;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Class1 {&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        Color c = new Color();&lt;br /&gt;
        int red = 1;&lt;br /&gt;
        int green = 2;&lt;br /&gt;
        int blue = 3;&lt;br /&gt;
        c.GetRGB(ref red, ref green, ref blue);&lt;br /&gt;
        Console.WriteLine(&amp;quot;R={0}, G={1}, B={2}&amp;quot;, red, green, blue);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use a parameter in a member function==&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 ChkNum {  &lt;br /&gt;
  // Return true if x is prime. &lt;br /&gt;
  public bool isPrime(int x) { &lt;br /&gt;
    for(int i=2; i &amp;lt;= x/i; i++) &lt;br /&gt;
      if((x %i) == 0) return false; &lt;br /&gt;
 &lt;br /&gt;
    return true; &lt;br /&gt;
  } &lt;br /&gt;
}  &lt;br /&gt;
  &lt;br /&gt;
class MainClass {  &lt;br /&gt;
  public static void Main() {  &lt;br /&gt;
    ChkNum ob = new ChkNum(); &lt;br /&gt;
 &lt;br /&gt;
    for(int i=1; i &amp;lt; 10; i++) &lt;br /&gt;
      if(ob.isPrime(i)) Console.WriteLine(i + &amp;quot; is prime.&amp;quot;); &lt;br /&gt;
      else Console.WriteLine(i + &amp;quot; is not prime.&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;1 is prime.&lt;br /&gt;
2 is prime.&lt;br /&gt;
3 is prime.&lt;br /&gt;
4 is not prime.&lt;br /&gt;
5 is prime.&lt;br /&gt;
6 is not prime.&lt;br /&gt;
7 is prime.&lt;br /&gt;
8 is not prime.&lt;br /&gt;
9 is not prime.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==use of &amp;quot;outer variable&amp;quot; in anonymous 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;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
    class Program&lt;br /&gt;
    {&lt;br /&gt;
        delegate void MessagePrintDelegate(string msg);&lt;br /&gt;
        static void Main(string[] args)&lt;br /&gt;
        {&lt;br /&gt;
            string source = &amp;quot;Outer&amp;quot;;&lt;br /&gt;
            MessagePrintDelegate mpd3 = delegate(string msg)&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine(&amp;quot;[{0}] {1}&amp;quot;, source, msg);&lt;br /&gt;
            };&lt;br /&gt;
            LongRunningMethod(mpd3);&lt;br /&gt;
        }&lt;br /&gt;
        static void LongRunningMethod(MessagePrintDelegate mpd)&lt;br /&gt;
        {&lt;br /&gt;
            for (int i = 0; i &amp;lt; 99; i++)&lt;br /&gt;
            {&lt;br /&gt;
                if (i % 25 == 0)&lt;br /&gt;
                {&lt;br /&gt;
                    mpd(string.Format(&amp;quot;Progress Made. {0}% complete.&amp;quot;, i));&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        static void PrintMessage(string msg)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;[PrintMessage] {0}&amp;quot;, msg);&lt;br /&gt;
        }&lt;br /&gt;
    }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use out for int type==&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 Val = 20;                     &lt;br /&gt;
}&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
   static void MyMethod(out MyClass f1, out int f2)&lt;br /&gt;
   {&lt;br /&gt;
      f1 = new MyClass();                   &lt;br /&gt;
      f1.Val = 25;                          &lt;br /&gt;
      f2 = 15;                              &lt;br /&gt;
   }&lt;br /&gt;
   static void Main()&lt;br /&gt;
   {&lt;br /&gt;
      MyClass myObject = null;&lt;br /&gt;
      int intValue;&lt;br /&gt;
      MyMethod(out myObject, out intValue);             &lt;br /&gt;
      Console.WriteLine(&amp;quot;After  -- myObject.Val: {0}, intValue: {1}&amp;quot;, myObject.Val, intValue);&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;After  -- myObject.Val: 25, intValue: 15&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Variable arguments to a method in C#.==&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;
    public static void PrintParams(params object[] list) {&lt;br /&gt;
        for (int i = 0; i &amp;lt; list.Length; ++i)&lt;br /&gt;
            Console.WriteLine(&amp;quot;Object {0} = {1} ({2})&amp;quot;, i, list[i], list[i].GetType());&lt;br /&gt;
    }&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        PrintParams(1, 2, &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;, 23.4);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>