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

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Articles >> C# >> Post New Resource Bookmark and Share   

 Subscribe to Articles


Posted By:Shashi Ray       Posted Date: February 28, 2009    Points: 25    Category: C#    URL: http://www.dotnetspark.com  



In C# as well as other object oriented languages, you can have several class methods with the same name as long as they have different calling arguments or signatures. For example we might want to create an instance of a StringTokenizer class where we define both the string and the



tok = new StringTokenizer("apples, pears", ",");


By declaring constructors with different numbers of arguments we say we are overloading the constructor. Here are the two constructors.


public StringTokenizer(string dataLine) {

init(dataLine, " ");



public StringTokenizer(string dataLine, string delim) {

init(dataLine, delim);


private void init(string data, string delim) {



Of course C# allows us to overload any method as long as we provide arguments that allow the compiler can distinguish between the various overloaded (or polymorphic) methods.



Shashi Ray

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

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