Tuesday 12 February 2013

Calling members of another class


//calling methods of another class by creating object

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpConsole
{
    class Testclasses
    {
        static void Main()
        {
            Method_ex m1= new Method_ex();     // m1 is a object created
            Params p1=new Params();            // p1 is a object created
            m1.Test1();                        // calling methods
            m1.Test2(6, 12);
            Console.WriteLine(m1.Test3());
            Console.WriteLine(m1.Test4("Hello"));
            p1.AddNums(100, 75, 50);

            int x = 0, y = 0;
            p1.Math1(100, 25, ref x, ref y);
            Console.WriteLine(x + "   " + y);
            p1.Math2(100, 50, out x, out y);
            Console.WriteLine(x+ "   "+y);
            Console.ReadLine();              // waiting to key press
        }

    }
}

No comments:

Post a Comment