using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; namespace ConsoleApp16 { class Program { class Calculrator //계산기 클래스 생성 { public int Plus(int a,int b) => a + b; public int Minus(int a, int b) => a - b; public int Multiple(int a, int b) => a * b; public double Divide(int a, int b) => (double)a / b; //캐스팅 } static void Main(string[] args) { Calculrator cal = new Calculrator(); Console.WriteLine( cal.Plus(5, 4)); Console.WriteLine(cal.Minus(5, 4)); Console.WriteLine(cal.Multiple(5, 4)); Console.WriteLine(cal.Divide(20, 5)); } } }
'코딩연습 > C#' 카테고리의 다른 글
[C#]윈폼(Windows Form)에 마우스 이벤트로 폼 배경 변경(랜덤) (1) | 2020.06.16 |
---|---|
[C#]문자열을 입력받아 아스키코드로 분류 (0) | 2020.06.16 |
[C#]식트리 (0) | 2020.06.15 |
[C#]람다식(Action대리자 (0) | 2020.06.15 |
[C#]람다식(Func대리자) (0) | 2020.06.15 |