Tuesday 21 February 2012

How To find Square of Number Using Constructor

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

namespace SquareNumber
{
    class Program
    {
        int n;
        public void Square(int n)
        {
            Console.WriteLine(n);
            n *= n;
            Console.Write(n);
        }
        Program()//Constructor
        {
            n = 10;
            Square(n);
        }

        static void Main(string[] args)
        {
            Program cal = new Program();
            Console.ReadLine();
        }
    }

}
Output:-

No comments: