为什么 System.Net.Http.HttpMethod 是 class,而不是枚举?

Why is System.Net.Http.HttpMethod a class, not an enum?

HttpStatusCode 实现为 enum,每个可能的值都分配给相应的 HTTP 状态代码(例如 (int)HttpStatusCode.Ok == 200)。

但是,HttpMethodimplemented as a class,具有静态属性以获取各种 HTTP 动词(HttpMethod.GetHttpMethod.Put 等)的实例。 HttpMethod实现为enum背后的基本原理是什么?

来自 documentation(强调我的):

Remarks

The most common usage of HttpMethod is to use one of the static properties on this class. However, if an app needs a different value for the HTTP method, the HttpMethod constructor initializes a new instance of the HttpMethod with an HTTP method that the app specifies.

枚举当然不可能。

查看其constructor and method property

之后,我想微软已经听到了你的愿望...

这是你想要的...

HttpVerb