// ?? null合体演算子 (nullでない場合は左の値、nullの場合は右の値)
string city = "Tokyo";
Debug.WriteLine(city ?? "null"); // Tokyo
city = null;
Debug.WriteLine(city ?? "null"); // null
// ?. null条件演算子(nullの場合、nullを返す)
Student student;
student = null;
string name = student?.name; // nameの値はnull
Debug.WriteLine(name ?? "null");
student = new Student() { name = "Tarou" };
name = student?.name; // nameの値は"Tarou"
Debug.WriteLine(name ?? "null");
class Student
{
public string name;
}