Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   use of param keyword in c# (http://www.go4expert.com/forums/param-keyword-c-sharp-t25568/)

Ritu_Pruthi 19Apr2011 22:28

use of param keyword in c#
 
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:

shabbir 20Apr2011 07:05

Re: use of param keyword in c#
 
You should be asking this question to the person who has written this program.


All times are GMT +5.5. The time now is 08:38.