๐ฎ GAME & DEV/ํ๋ก๊ทธ๋๋ฐ
New Syntax in C# 8.0
Blue Sky!
2020. 6. 1. 14:46
C# 8.0 ์์ ๋ฐ๋์
1. Defalut Interface ๊ฐ ์๊น
interface Test
{
void DefalutFunc()
{
.....
}
}
2. Using ๊ฐ์
using ๋ธ๋ญ ์ฌ์ฉ์ ๊ฐ์ ํ์ฌ ์๋์ ๊ฐ์ด ์ฌ์ฉ์ด ๊ฐ๋ฅํ๋ค
public static void Test
{
using FileSystem test = new FileSystem("text.txt",FileMode.CreateNew);
} // test Dispose
3. Nullable Reference
#nullable enable : ์ฐธ์กฐ ํ์ ๋ณ์๋ฅผ null ์ ๋์ ํ๋ฉด ๊ฒฝ๊ณ ๋ฅผ ๋ฐ์์ํจ๋ค. (#nullable disable : ์ฌ์ฉ์ํจ)
4. Null ๋ณํฉ ํ ๋น์
c# 6.0 null ๋ณํฉ ์ฐ์ฐ์
string s2 = s1 ?? "hello";
-> s1์ด null ์๋๋ฉด s1 ๋์ , null ์ด๋ฉด hello ๋ฆฌํด
c# 8.0 null ๋ณํฉ ๋์
s1 ??= "world" ;
-> if ( s1 == null ) s1 ="world";