void(C# 参考)void (C# Reference)

当用作一种方法的返回类型时,void 将指定该方法不返回值。When used as the return type for a method, void specifies that the method doesn't return a value.

方法的参数列表中不允许有 voidvoid isn't allowed in the parameter list of a method. 无参数且不返回值的方法的声明方式如下:A method that takes no parameters and returns no value is declared as follows:

public void SampleMethod()
    // Body of the method.

void 还可用于在不安全的上下文中将指针声明为未知类型。void is also used in an unsafe context to declare a pointer to an unknown type. 有关详细信息,请参阅指针类型For more information, see Pointer types.

void 是 .NET Framework System.Void 类型的别名。void is an alias for the .NET Framework System.Void type.

C# 语言规范C# language specification

有关详细信息,请参阅 C# 语言规范For more information, see the C# Language Specification. 该语言规范是 C# 语法和用法的权威资料。The language specification is the definitive source for C# syntax and usage.

请参阅See also