c#演算式:【X?.x】.cs の用例
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Rextester
{
public class SampleModel
{
public string id { get; set; }
}
public class Program
{
public static void Main(string[] args)
{
SampleModel sampleModel = null;
Console.WriteLine("|" + sampleModel?.id + "|");
try{
if (string.IsNullOrWhiteSpace(sampleModel?.id))
{
Console.WriteLine("1111");
}
} catch(Exception ex){
Console.WriteLine(ex);
}
}
}
}
Onlineツール: https://rextester.com/