C# null传播运算符(c# ?.)

c# ?.

相关报错:
Feature `null propagating operator’ cannot be used because it is not part of the C# 4.0 language specification

a?.sort() 的用法相当于

if(a != null)
	a.sort();

也可以将编辑器设置脚本运行时的版本为 .NET 4.x
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/ABCGods/article/details/123714574
今日推荐