C#
  Home arrow C# arrow Page 3 - C# Simplified, part 2: Methods & Programmi...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C#

C# Simplified, part 2: Methods & Programming Constructs
By: Anand Narayanaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 16
    2005-05-10

    Table of Contents:
  • C# Simplified, part 2: Methods & Programming Constructs
  • Declaring methods with parameters
  • Overloading Methods
  • Different types of programming constructs in C#
  • Different types of looping statements in C#
  • break Statement

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    C# Simplified, part 2: Methods & Programming Constructs - Overloading Methods


    (Page 3 of 6 )

    In listing 2.5, we declared a single method named display(). This method contains two integer parameters. You can also declare the same method once again in the same class, but it should contain different parameters. This process is known as Method Overloading.

    If you attempt to declare the method with the same parameter, then the C# compiler won't know which one is the correct method, and there will be compilation errors. Listing 2.6 declares two methods named display(). The first method is declared with one integer parameter and the second one with two integer parameters. Inside the Main() method, show() method is called by passing the respective values.

    Listing 2.6

    using System;

    class Methodover

    {

    //Method display() declared with one integer parameter

    void display(int x)

    {

    Console.WriteLine(x);

    }

    //Method display() declared with two integer parameters

    void display(int a, int b)

    {

    Console.WriteLine(a);

    Console.WriteLine(b);

    }

    public static void Main()

    {

    //Object of the class created

    Overloadmethod over = new Overloadmethod ();

    //display() Method called by passing respective values

    over.display(400);

    over.display(600,800);

    }

    }

    More C# Articles
    More By Anand Narayanaswamy


     

    C# ARTICLES

    - C# and XML
    - Pointers and Arrays in C#
    - C# 3.0 Extension Methods
    - Overloading Operators in C#
    - Iterators and Nullable Types
    - Patterns and Iterators in C#
    - C# Exceptions
    - Methods in C#
    - Delegates and Events in C#
    - Advanced C#
    - Working with Regular Expressions in C#
    - Sending Simple E-Mail in C#
    - Building C# Comparable Objects: IComparable ...
    - Color Transformation Applications in C# GDI+...
    - Performing Color Transformation Operations i...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT