小编Tee*_*Tee的帖子

C#中的花括号

我在玩一些代码,我想知道是否有人可以告诉我这段代码中的花括号代表什么。我以为这是一个空对象,但似乎并非如此。

 Person person = new Person{};

            if (person is {}){
                Console.WriteLine("Person is empty.");
            } else {
                Console.WriteLine("Person is not empty.");
            }
Run Code Online (Sandbox Code Playgroud)

它编译得很好;但是如果我填充了 person 类的属性,它仍然属于 if 语句的 person is empty 部分。

c# syntax

5
推荐指数
1
解决办法
608
查看次数

标签 统计

c# ×1

syntax ×1