Please use. NET 5,. NET 6, NET 7,. NET 8, NET Framework 4.6, NET Framework 4.61, NET Framework 4.7, NET Framework 4.72, NET Framework 4.8, NET Framework 4.81, and. NET Core 3.1 versions

EnumExtensionsGetDisplayName 方法

Gets the display name for an enum value as specified by DisplayNameAttribute 获取枚举值的显示名称(通过DisplayNameAttribute指定)

Definition

命名空间: DeploySharp.Engine
程序集: DeploySharp (在 DeploySharp.dll 中) 版本:0.0.4+6e8a2e904469617cd59619d666c0e272985c0e33
C#
public static string GetDisplayName(
	this Enum value
)

参数

value  Enum
The enum value to get the display name for 要获取显示名称的枚举值

返回值

String
The display name if specified by DisplayNameAttribute, otherwise the enum value's string representation 如果通过DisplayNameAttribute指定了显示名称则返回该名称,否则返回枚举值的字符串表示

备注

在 Visual Basic 和 C# 中,这个方法可以当成为类型 Enum 的实例方法来调用。在采用实例方法语法调用这个方法时,请省略第一个参数。请参考 扩展方法 (Visual Basic)扩展方法 (C# 编程指南) 获取更多信息。

示例

C#
var name = DeviceType.CPU.GetDisplayName(); // Returns "CPU"
var name = InferenceBackend.OpenVINO.GetDisplayName(); // Returns "OpenVINO"

参见