为什么System.Net.Http.HttpMethod是类而不是枚举? [英] Why is System.Net.Http.HttpMethod a class, not an enum?
本文介绍了为什么System.Net.Http.HttpMethod是类而不是枚举?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HttpStatusCode
被实现为enum
,每个可能的值都分配给其相应的HTTP状态代码(例如(int)HttpStatusCode.Ok == 200
).
HttpStatusCode
is implemented as an enum
, with each possible value assigned to its corresponding HTTP status code (e.g. (int)HttpStatusCode.Ok == 200
).
However, HttpMethod
is implemented as a class
, with static properties to get instances for the various HTTP verbs (HttpStatus.GET
, HttpStatus.PUT
etc). What is the rationale behind not implementing HttpMethod
as an enum
?
推荐答案
查看全文