.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Different Type of argument.

Posted By:laptop charles       Posted Date: August 27, 2010    Points: 10    Category: Visual Studio    URL: http://www.dotnetspark.com  

Using constructor different argument.
 

It has used four type of argument.
int,float,double,float.
using System;
using System.Collections.Generic;
using System.Text;

namespace Different_type_of_constructor
{
    class Program
    {
        class Charles
        {
            int a, b;
            public Charles(int x, int y)
            {
                a = x;
                b = y;

                
            }
            public void disp()
            {
                Console.WriteLine("Integer ={0},{1}", a, b);
            }

            public Charles(float q)
            {
                Console.WriteLine("Float ={0}",q);

            }
            public Charles(double p)
            {
                Console.WriteLine("Double ={0}", p);

            }
            public Charles(String s)
            {
                Console.WriteLine("string ={0}", s);

            }
           

           

        }
        class main
        {
            static void Main(string[] args)
            {
                Charles c = new Charles(10, 20);
                Charles c1 = new Charles(10.000000);
                Charles c2 = new Charles(30.00);
                Charles c3 = new Charles("charles");
                c.disp();
               

                Console.ReadLine();
            }
        }
    }
}

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend