Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Use void as the return type of a method or a local function to specify that the method doesn't return a value.
The C# language reference documents the most recently released version of the C# language. It also contains initial documentation for features in public previews for the upcoming language release.
The documentation identifies any feature first introduced in the last three versions of the language or in current public previews.
Tip
To find when a feature was first introduced in C#, consult the article on the C# language version history.
public static void Display(IEnumerable<int> numbers)
{
if (numbers is null)
{
return;
}
Console.WriteLine(string.Join(" ", numbers));
}
You can also use void as a referent type to declare a pointer to an unknown type. For more information, see Pointer types.
You can't use void as the type of a variable.