1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

use of param keyword in c#

Discussion in 'C#' started by Ritu_Pruthi, Apr 19, 2011.

  1. Ritu_Pruthi

    Ritu_Pruthi New Member

    Joined:
    Apr 19, 2011
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    //file name wrappedint
    namespace Parameters
    {
            class WrappedInt
            {
            public int Number;
            }
    }
    
    //file name program
    namespace Parameters
    {
        class Program
        {
            static void Entrance()
            {
                int i = 0;
                Console.WriteLine(i);
                Pass.Value(i);
                Console.WriteLine(i);
                WrappedInt wi = new WrappedInt();
                Console.WriteLine(wi.Number);
                Pass.Reference(wi);
                Console.WriteLine(wi.Number);
            }
            static void Main(string[] args)
            {
                try
                {
                    Entrance();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
    }using System;
    
    //file name pass
    namespace Parameters
    {
            class Pass
            {
            public static void Value(int param)
            {
                param = 42;
            }
            public static void Reference (WrappedInt param)
            {
                param.Number = 42;
            }
            }
    }
    can anyone tell me the output of this program and how it is working ?:nonod:
     
    Last edited by a moderator: Apr 20, 2011
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,292
    Likes Received:
    365
    Trophy Points:
    83
    You should be asking this question to the person who has written this program.
     

Share This Page