Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Delegate test lambda
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here Console.WriteLine("Hello, world!"); Console.WriteLine(PerformOperation("+",3.2,4)); Console.WriteLine(PerformOperation("-",3.2,4)); Console.WriteLine(PerformOperation("*",3.2,4)); Console.WriteLine(PerformOperation("/",3.2,4)); } static private Dictionary<string, Func<double, double, double>> _operations = new Dictionary<string, Func<double, double, double>> { { "+", (x, y) => x + y }, { "-", (x, y) => x - y }, { "*", DoMultiplication }, { "/", DoDivision }, }; static private double DoDivision(double x, double y) { return x / y; } static private double DoMultiplication(double x, double y) { return x * y; } static public double PerformOperation(string op, double x, double y) { if (!_operations.ContainsKey(op)) throw new ArgumentException(string.Format("Operation {0} is invalid", op), "op"); return _operations[op](x, y); } } }
run
|
edit
|
history
|
help
0
Generic class and method example in C#
Jai
EFCXAXS
puzzle piezas
test device logger
The given number is prime or even
Unity Character Controller Version 1
see all properties of given ldap node
LINQ-Group BY
Find Highest,Lowest and average using two dimensional arrays