Skip to content

Instantly share code, notes, and snippets.

@tnngo2
Created April 27, 2012 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tnngo2/2506990 to your computer and use it in GitHub Desktop.
Save tnngo2/2506990 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Theory8
{
interface IMaths<T>
{
T Addition(T valOne, T valTwo);
T Subtraction(T valOne, T valTwo);
}
class Numbers: IMaths<int>
{
public int Addition(int valOne, int valTwo)
{
return valOne + valTwo;
}
public int Subtraction(int valOne, int valTwo)
{
if (valOne > valTwo)
{
return (valOne - valTwo);
}
else
{
return (valTwo - valOne);
}
}
static void Main(string[] args)
{
int numOne = 23;
int numTwo = 45;
Numbers objInterface = new Numbers();
Console.WriteLine("Addition of two integer value is: ");
Console.WriteLine(objInterface.Addition(numOne, numTwo));
Console.WriteLine("Subtraction of two integer value is: ");
Console.WriteLine(objInterface.Subtraction(numOne, numTwo));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment