Wednesday, July 24, 2013

Printing of characters of String in Reverse Order in C Sharp

//File Name: reverse
//Author: SURESH BABU
//Reference: Printing of characters of String in Reverse Order

using System;


namespace reverse
{
    class Program
    {
        static void Main(string[] args)
        {
            string name = "SURESH BABU";
            string reverse = "";
            foreach (char ch in name)
            {
                reverse = ch +reverse;
            }
            Console.WriteLine(reverse);
        }
    }
}

Example for Copy Constructor in C Sharp

Example for copy Constructor:

//Fileno: demo_49
//Author: SURESH BABU
//Reference: Copy Constructor

using System;


namespace demo_49
{
    public class CopyConstruct
    {
        private int x, y;
        public CopyConstruct(int a, int b)
        {
            x=a;
            y=b;
        }
        public  CopyConstruct(CopyConstruct T)
        {
           x=   T.x;
           y =  T.y;
        }
        public void show()
        {
            Console.WriteLine("The value of x and y are {0} and {1}",x,y);
        }
        public void print()
        {
            Console.WriteLine("The value of a and b are {0} and {1}",x,y);
        }


    }
    class Program
    {
        static void Main(string[] args)
        {
            CopyConstruct t3 = new CopyConstruct(80,90);
           
            CopyConstruct t2 = new CopyConstruct(t3);
            t2.show();
            t2.print();
           

        }
    }
}