Passing Arguments to Constructor in C#

aaaaaaaaaaaaaaaaa

Constructor Simple Program

Program

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

namespace ConsoleApplication
{
    public class Program
    {
        public string firstname, lastname;
        public int rollno;
        public Program()
        {
            firstname = "HiLaLs";
            lastname = "Afridi";
            rollno = 120122067;
        }
        static void Main(string[] args)
        {
            Program p = new Program(); //'p' is object of class 'Program' and calling Constructor.
                  //with the help of 'p.' printing strings and integers.
            Console.Write(p.firstname);
            Console.WriteLine(p.lastname);
            Console.WriteLine(p.rollno);
            Console.ReadKey();
        }
    }
}
Output
Hello World!

Constructor Passing String and Integer to Parameter

Program

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

namespace ConsoleApplication1
{
    public class Program
    {
        public string name;
        public int rollno;
        public Program(string na) //Argument'HiLaLs' passing here to Parameter'na'.
        {
            name = na; //assigning 'na' value to 'name'.
            Console.WriteLine(name);
        }
        public Program(int rn) //Argument'120122067' passing here to parameter'rn'.
        {
            rollno = rn; //assigning 'rn' value to 'rollno'.
            Console.WriteLine(rollno);
        }
        static void Main(string[] args)
        {
            Program p1 = new Program("HiLaLs");
            Program p2 = new Program(120122067);
            Console.Read();
        }
    }
}
Output
Hello World!

Constructor Passing String and Integer another Method

Program

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

namespace ConsoleApplication
{
    public class Program
    {
        public int rollno;
        public int classno, mobileno;
        public string name;
        public string fathername, department;
        public Program(int rn) //passing here argument to 'rn'.
        {  //assigning 'rn' value to 'rollno' and printing.
            rollno = rn;
            Console.WriteLine(rollno);
        }
        public Program(int cn, int mn) //passing here arguments to 'cn' and 'mn'.
        {
            classno = cn; //assigning to 'cn' value to 'classno' and printing.
            mobileno = mn;//assigning to 'mn' value to 'mobileno' and printing.
            Console.WriteLine(classno);
            Console.WriteLine(mobileno); //If U using one line for printing
	       //this two 'classno' and 'mobileno' in one line then write
        } //'Console.WriteLine(classno+" \n"+mobileno);',pluss '+' is must.
        public Program(string n) //passing here argument to 'n'.
        {
            name = n; //assigning 'n' value to 'name'.
        }
        public Program(string fn, string d) //passing here arguments to 'fn' and 'd'.
        {
            fathername = fn; //assigning 'fn' value to 'fathername'.
            department = d; //assigning 'd' value to 'department'.
        }
        public void shownames() //this is function not constructor.
        {
            Console.Write(name);
            Console.WriteLine(fathername);
            Console.WriteLine(department);
        }
        static void Main(string[] args)
        {  //this is another method using object for calling.
            Program p1, p2, p3, p4;
            p1 = new Program(120122067); //passing argument to parameter.
            p2 = new Program(13, 9777098);//passing arguments to parameter.
            p3 = new Program("HiLaLs"); //passing argument to parameter.
            p4 = new Program("M'Aslam", "BsCs");//passing arguments to parameter.
            p3.shownames();
            p4.shownames();
            Console.ReadLine();
        }
    }
}
Output
Hello
World!