using System.Threading.Tasks;
static async Task Main(string[] args)
Console.WriteLine("Hello World!");
var foo = new Foo<double>(1.5d);
foo.LogToConsole("Hello world");
await foo.LogtoFile("Hello world");
var result1 = Foo<double>.DoCalc(1, 2);
var result2 = Foo<double>.higherOrderCalculation((x, y) => x + y, 3, 4);
Console.WriteLine("result 1: " + result1);
Console.WriteLine("result 2: " + result2);
static protected T StartValue { get; private set; }
public static int DoCalc(object arg1, T arg2)
if (int.TryParse(arg1.ToString(), out outArg1))
return outArg1 + Convert.ToInt32(arg2) / Convert.ToInt32(StartValue);
catch (OverflowException e)
Console.WriteLine(e.Message);
Console.WriteLine(e.Message);
throw new ArgumentException("arg1 cannot be converted to integer");
public static T higherOrderCalculation(Func<T, T, T> Func, T one, T two)
public void LogToConsole(string message)
Console.WriteLine(message);
public async Task LogtoFile(string msg)
await File.AppendAllTextAsync($"logfile{DateTime.Now.ToString("dd-MM-yyyy")}.log", msg);