Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
using System;
namespace Calculator
{
public class Calculator : IOperand
{
public Calculator()
{
}
public float Add(float a, float b)
{
return a + b;
}
public float Subtract(float a, float b)
{
return a - b;
}
public float Multiply(float a, float b)
{
return a * b;
}
public float Divide(float a, float b)
{
return a/b;
}
}
interface IOperand
{
float Add(float a, float b);
float Subtract(float a, float b);
float Multiply(float a, float b);
float Divide(float a, float b);
}
}
using System;
namespace Calculator
{
public class ConsoleCalculator
{
[STAThread]
static void Main(string[] args)
{
Calculator myCalculator = new Calculator();
Console.WriteLine("Add 24 to 78 " + Convert.ToString(myCalculator.Add(24, 78)));
}
}
}
using System;
class clsDelegate
{
public delegate float simpleDelegate (float a, float b);
public float Add(float a, float b)
{
return (a+b);
}
public float Multiply(float a, float b)
{
return (a*b);
}
//.....the rest
static void Main(string[] args)
{
clsDelegate clsDlg = new clsDelegate();
simpleDelegate addDelegate = new simpleDelegate(clsDlg.Add);
simpleDelegate mulDelegate = new simpleDelegate(clsDlg.Multiply);
float addAns = addDelegate(10,12);
float mulAns = mulDelegate(10,10);
Console.WriteLine("Result by calling the Add method using a delegate: {0}",addAns);
Console.WriteLine("Result by calling the Multiply method using a delegate: {0}",mulAns);
float addAns1 = clsDlg.Add(10,12);
float mulAns1 = clsDlg.Multiply(10,10);
Console.WriteLine();
Console.WriteLine("Result by calling the Add method not using a delegate: {0}",addAns1);
Console.WriteLine("Result by calling the Multiply method not using a delegate: {0}",mulAns1);
Console.Read();
}
}