Linq的Sum() 加和
int maxWealth = int.MinValue;
foreach (int[] account in accounts) {
maxWealth = Math.Max(maxWealth, account.Sum());
}
null! 告诉编译器这个null不是null!!!!
//例子1
namespace ContosoPizza.Models
{
public partial class Coupon
{
public long Id { get; set; }
public string Description { get; set; } = null!;
public DateTime Expiration { get; set; }
}
}
//例子2
string x;
string? y = null;
x = y;//这里编译器会报错
x = y!;
Console.WriteLine($"x={x},y={y}");