Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 15342 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > C# > Write a code snippet to show parameterized constructor? ...
Tripati_tutu

Write a code snippet to show parameterized constructor?

 Code Snippet posted by: Tripati_tutu | Posted on: 12/3/2010 | Category: C# Codes | Views: 1433 | Status: [Member] | Points: 40 | Alert Moderator   
Ads

using System;

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

namespace ParameterizedConst
{
class Program
{
int Eno;
string Ename;
int Esal;
public Program(int Eno1, string Ename1, int Esal1) // parameterized constructor
{
// Here Eno1, Ename1, Esal1 are called as local variables.
Eno = Eno1;
Ename = Ename1;
Esal = Esal1;
}
static void Main(string[] args)
{
Program obj1 = new Program(101, "ravi", 7800);
Console.WriteLine(obj1.Eno + " " + obj1.Ename + " " + obj1.Esal);
Program obj2 = new Program(102, "sham", 12000);
Console.WriteLine(obj2.Eno + " " + obj2.Ename + " " + obj2.Esal);
Console.ReadKey();
}
}
}


In this type of constructors, you can assign different values for different objects according to your requirement.
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/19/2013 6:17:26 PM