В C# запись T? используется в двух разных контекстах — и это может запутать даже опытных разработчиков.
• Nullable Value Types
Тут T? — это реально другой тип. int? — это Nullable<int>, со своими методами HasValue, Value. Вы получаете объект, который может быть пустым:
int? age = GetAge(); if (age.HasValue) Console.WriteLine(age.Value);
• Nullable Reference Types
А тут T? — это не новый тип, а подсказка компилятору: «Эта ссылка может быть null — предупреди меня, если я забуду это проверить.» Во время выполнения — всё равно просто T:
string? name = GetName(); Console.WriteLine(name.Length); // ⚠️ warning: возможно null!
В C# запись T? используется в двух разных контекстах — и это может запутать даже опытных разработчиков.
• Nullable Value Types
Тут T? — это реально другой тип. int? — это Nullable<int>, со своими методами HasValue, Value. Вы получаете объект, который может быть пустым:
int? age = GetAge(); if (age.HasValue) Console.WriteLine(age.Value);
• Nullable Reference Types
А тут T? — это не новый тип, а подсказка компилятору: «Эта ссылка может быть null — предупреди меня, если я забуду это проверить.» Во время выполнения — всё равно просто T:
string? name = GetName(); Console.WriteLine(name.Length); // ⚠️ warning: возможно null!
Hashtags are a fast way to find the correct information on social media. To put your content out there, be sure to add hashtags to each post. We have two intelligent tips to give you: With Bitcoin down 30% in the past week, some crypto traders have taken to Telegram to “voice” their feelings. Ng Man-ho, a 27-year-old computer technician, was convicted last month of seven counts of incitement charges after he made use of the 100,000-member Chinese-language channel that he runs and manages to post "seditious messages," which had been shut down since August 2020. 2How to set up a Telegram channel? (A step-by-step tutorial) Developing social channels based on exchanging a single message isn’t exactly new, of course. Back in 2014, the “Yo” app was launched with the sole purpose of enabling users to send each other the greeting “Yo.”
from us