string?的意思

date
Jul 25, 2022
slug
10011
status
Published
tags
C#
summary
type
Post
Console.Write("Type your first name and press ENTER: ");
string? firstName = Console.ReadLine();
Console.Write("Type your age and press ENTER: ");
string? age = Console.ReadLine();
Console.WriteLine(
$"Hello {firstName}, you look good for {age}.");
The question marks at the end of the string? data type declaration indicate that we acknowledge that a null (empty) value could be returned from the call to ReadLine.

© Wen Bo 2021 - 2022