[Csharp]
/* (Start of program header annotation)
* Copyright and version Declaration of the program
* Copyright (c) 2011, a student from the computer College of Yantai University
* All rights reserved.
* File name: calculates the sum of two numbers.
* Author: Xue Guangchen
* Completion date: January 1, September 19, 2012
* Version No.: X1.0
* Description of tasks and Solutions
* Input Description: Create an abstract class A, which contains an abstract Method for Calculating the sum of two numbers.
* Create a subclass B, rewrite the summation method in B, and use method overload to calculate integers, double precision, and strings respectively.
* Problem description:
* Program output:
* End the comment in the program Header
*/
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Namespace Calculate
{
Class Program
{
Static void Main (string [] args)
{
B B = new B ();
B. summation ("abcd", "efg ");
B. summation (6, 9 );
B. summation (7.5, 6.3 );
Console. ReadKey ();
}
}
Abstract class
{
Public abstract void summation (int I, int j );
}
Class B:
{
Public override void summation (int I, int j)
{
Console. WriteLine (I + j );
}
Public void summation (double I, double j)
{
Console. WriteLine (I + j );
}
Public void summation (string I, string j)
{
Console. WriteLine (I + j );
}
}
}
Running result: