Method overloading test : Class Method « Language Basics « C# / C Sharp

C# / C Sharp
1. 2D Graphics
2. Collections Data Structure
3. Components
4. Database ADO.net
5. Development Class
6. Event
7. File Stream
8. GUI Windows Form
9. Language Basics
10. Network
11. Office
12. Regular Expressions
13. Services Event
14. Thread
15. Web Services
16. Windows
17. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
C# / C Sharp » Language Basics » Class MethodScreenshots 
Method overloading test
Method overloading test

/*
Learning C# 
by Jesse Liberty

Publisher: O'Reilly 
ISBN: 0596003765
*/
 using System;

 namespace MethodOverloading
 {
     public class Time1
     {
         // private member variables
         private int Year;
         private int Month;
         private int Date;
         private int Hour;
         private int Minute;
         private int Second;

         // public accessor methods
         public void DisplayCurrentTime()
         {
             System.Console.WriteLine("{0}/{1}/{2} {3}:{4}:{5}",
                 Month, Date, Year, Hour, Minute, Second);
         }

         // constructors
         public Time1(System.DateTime dt)
         {
             Year =      dt.Year;
             Month =     dt.Month;
             Date =      dt.Day;
             Hour =      dt.Hour;
             Minute =    dt.Minute;
             Second =    dt.Second;
         }

         public Time1(int Year, int Month, int Date,
             int Hour, int Minute, int Second)
         {
             this.Year =     Year;
             this.Month =    Month;
             this.Date =     Date;
             this.Hour =     Hour;
             this.Minute =   Minute;
             this.Second =   Second;
         }
     }

    public class MethodOverloadingTester
    {
       public void Run()
       {
           System.DateTime currentTime = System.DateTime.Now;

           Time1 time1 = new Time1(currentTime);
           time1.DisplayCurrentTime();

           Time1 time2 = new Time1(2000,11,18,11,03,30);
           time2.DisplayCurrentTime();
       }

       static void Main()
       {
          MethodOverloadingTester t = new MethodOverloadingTester();
          t.Run();
       }
    }
 }

           
       
Related examples in the same category
1. Define methods that return a value and accept parametersDefine methods that return a value and accept parameters
2. Class a class methodClass a class method
3. Call class methods 2Call class methods 2
4. Add a method to BuildingAdd a method to Building
5. A simple example that uses a parameterA simple example that uses a parameter
6. Add a method that takes two argumentsAdd a method that takes two arguments
7. Use a class factoryUse a class factory
8. Return an arrayReturn an array
9. Demonstrate method overloadingDemonstrate method overloading
10. Automatic type conversions can affect overloaded method resolutionAutomatic type conversions can affect 
   overloaded method resolution
11. A simple example of recursionA simple example of recursion
12. Overloading ClassesOverloading Classes
13. C# Classes Member FunctionsC# Classes Member Functions
w__ww___.__j__a__v__a___2__s_.___c__om__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.