Friday 23 January 2015

C # Basic Programs to print a line using various methods

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

namespace Csharptestapplication
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Box");
            Console.Write("Table");
            Console.Write("chair");
            Console.WriteLine();
            Console.WriteLine("desk");
          //  Console.ReadLine();
            //Console.ReadKey();
           // Console.Read();
        }
    }
}

-----------------------------------------------------------------------------------------

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

namespace Test3
{
    class Program
    {
        static void Main(string[] args)
        {
            Program.test();
        }

        public static void test()
        {
            Console.WriteLine("hi World");
        }
    }
}

-----------------------------------------------------------------------------------------

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

namespace Test4
{
    class Program
    {
        static void Main(string[] args)
        {
            a ob = new a();
            ob.test();
        }
    }

    class a
    {
        public void test()
        {
            Console.WriteLine("hi World");
        }
    }
}

-----------------------------------------------------------------------------------------

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

namespace Test5
{
    class Program
    {
        static void Main(string[] args)
        {
            a.test();
        }
    }

    class a
    {
        public static void test()
        {
            Console.WriteLine("hi World");
        }
    }

}

-----------------------------------------------------------------------------------------


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

namespace Test6
{
    class Program
    {
        static void Main(string[] args)
        {
            a ob1 = new a();
            ob1.test1();

            b ob2 = new b();
            ob2.test2();

        }
    }

    class a
    {
        public void test1()
        {
            Console.WriteLine("hi World 1");
        }
    }

    class b
    {
        public void test2()
        {
            Console.WriteLine("hi World 2");
        }
    }

}

-----------------------------------------------------------------------------------------

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

namespace Test7
{
    class Program
    {
        static void Main(string[] args)
        {
            a ob = new a();
            ob.test1();
            ob.test2();
          
        }
    }

    class a
    {
        public void test1()
        {
            Console.WriteLine("hi World 1");
        }

        public void test2()
        {
            Console.WriteLine("hi World 2");
        }
    }
}
-----------------------------------------------------------------------------------------

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

namespace Test8
{
    class Program
    {
        static void Main(string[] args)
        {
            b ob = new b();
            ob.test1();
            b.test2();
        }
    }

    class a
    {
        public void test1()
        {
            Console.WriteLine("hi world 1");
        }
    }

    class b:a
    {
        public static void test2()
        {
            Console.WriteLine("hi world 2");
        }
    }
}

-----------------------------------------------------------------------------------------

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

namespace Test9
{
    class Program:a
    {
        static void Main(string[] args)
        {
            Program ob = new Program();
            ob.test1();
            ob.test2();
        }

        public void test2()
        {
            Console.WriteLine("hi world 1");
        }
    }

    class a
    {
        public void test1()
        {
            Console.WriteLine("hi world 2");
        }
    }
}


No comments:

Post a Comment