메서드에 적용할 수 있는 수정자들
정적 수정자 | static |
---|---|
접근 수정자 | public, internal, private, protected |
상속 수정자 | new, virtual, abstract, override, sealed |
부분 메서드 수정자 | partial |
비관리 코드 수정자 | unsafe, extern |
비동기 코드 수정자 | async |
int Foo (int x) { return x * 2; }
int Foo (int x) => x * 2; // 위 코드와 동일
void Foo (int x) => Console.WriteLine(x); // 반환형이 void인 함수도 이런 식으로 사용할 수 있다.
using System;
public class Wine
{
public decimal Price;
public int Year;
public Wine (decimal price) { Price = price; }
public Wine (decimal price, int year) : this (price) { Year = year; }
}
public decimal Worth => currentPrice * sharesOwned;
public decimal CurrentPrice { get; set; } = 123;
public int Maximum { get; } = 999;