Benj,

Thank you very much.

On Tue, Dec 9, 2008 at 9:04 PM, Benj Nunez <[EMAIL PROTECTED]> wrote:

>
>
> 1) First thing you need to do is modify the change() parameter from
> "pass by value"  to "pass by reference". Thus:
>
> public void change(ref int c)
> {
>      c = a + b;
> }
>
> 2) Then declare an integer variable within your Main() block which
> will hold the value from your change() method like:
>
> class Average
> {
>    public static void Main()
>    {
>        int result = -1;    // initiliaze the local variable. Required.
>
>        Test  ob = new Test(12,13);
>         ob.change(ref result);
>        Console.WriteLine("The answer is: {0}", result);     //
> output: 25
>        ...
>    }
> }
>
>
> Cheers!
>
>
> Benj
>
>
>
>
> On Dec 9, 3:14 am, DotnetBeginner <[EMAIL PROTECTED]> wrote:
> > Created a method and i would like to now how to call this change()
> > method on ob.Could any one help me on this
> > class Test
> > {
> >   //summation
> >     public int a, b;
> >      public Test(int i, int j)
> >      {
> >          a = i;
> >          b = j;
> >      }
> >     public void change(int c)
> >     {
> >         c= a+b;
> >
> >     }}
> >
> > class Average
> > {
> >     public static void Main()
> >     {
> >         Test  ob = new Test(12,13);
> >         ob.change(-----);
> >         Console.WriteLine(----);
> >     }
> >
> > }
>



-- 
Thanks,

Sushma

Email: [EMAIL PROTECTED]

Mobile: (571) 438 1206

Reply via email to