/// <summary> /// ウインドウがロードされた場合に呼び出されます。 /// </summary> /// <param name="sender">送信元</param> /// <param name="e">イベント情報</param> private async void MainWindow_Loaded(object sender, RoutedEventArgs e) { // このサンプルコードでは、ICalculatorHostを直接実装したので、自分自身をホストとして依存注入する await CalculatorImplementation.CalculateAsync(this); // 終了 this.Close(); }
public static Task Main(string[] args) { // コンソールに入出力を行うICalculatorHostインターフェイスの実装 ICalculatorHost host = new ConsoleHost(); // 引数から依存注入を行い、計算の入出力をコンソールに接続する return(CalculatorImplementation.CalculateAsync(host)); }
static void Main(string[] args) { CalculatorImplementation ci = new CalculatorImplementation(); ci.Add(10, 20); ci.Sub(20, 10); ci.Mul(10, 20); ci.Div(20, 10); ci.Tp(); }
static void Main(string[] args) { // create an instance of the derived class // and upcast it to the abstract type AbstractCalculator calc = new CalculatorImplementation(); // call the methods defined in the abstract class int result1 = calc.CalculateSum(100, 120); int result2 = calc.CalculateProduct(100, 120); // print out the results Console.WriteLine("Sum Result: {0}", result1); Console.WriteLine("Product Result: {0}", result2); // wait for input before exiting Console.WriteLine("Press enter to finish"); Console.ReadLine(); }
static void Main(string[] args) { //variable initialization double number1; double number2; string operador; double resultado = 0; bool isOk = false; Console.WriteLine("Hi! Welcome to Juli's app calculator. Please press enter to continue"); Console.ReadKey(); Console.WriteLine("now, you will be asked to enter two numbers and then the operand u wanna use"); Console.WriteLine("Please enter a number: "); number1 = double.Parse(Console.ReadLine()); Console.WriteLine("Please enter a number: "); number2 = double.Parse(Console.ReadLine()); while (!isOk) { Console.WriteLine("Please enter operation u wanna use, only +, -, *, / are allowed: "); operador = Console.ReadLine(); if (Validations.operatorIsOk(operador)) { resultado = Math.Round(CalculatorImplementation.realizarCalculo(number1, number2, operador), 2); isOk = true; } else { Console.WriteLine("Please enter a valid operator"); isOk = false; } } Console.WriteLine("Operation's result rounded to 2 decimales is: {0}", resultado); Console.Write("Thanks for using Juli's calculator, hope u have a nice experience. See u"); Console.ReadKey(); }