本文介绍了将查询参数转换为枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个看起来有点像这样的枚举:


私有枚举MyEnum

{

SomeValue = 0 ,

AnotherValue = 1,

ThirdValue = 2

}

我有一个会传入的网址像这样的价值,我想把这个枚举:






我想使用Request.QueryString来检索MyParameter

值(等于SomeValue)并将其转换为类型为en />
MyEnum的枚举。有没有一种快速简便的方法,或者我会建立一个选择案例来检查所有可能来的价值

in?
/>

解决方案





- 显示引用的文字 -



我在其中任何一个都没有看到Parse函数只是枚举对象,

我的实际枚举对象或我用我的枚举类型创建的变量

对象。你能给我发一个链接来查看解析函数吗?

enum'的?




- 显示引用文本 -



我没有看到任何一个Parse函数枚举对象,

我的实际枚举对象或我用我的枚举类型创建的变量

对象。你能给我发一个链接来查看解析函数吗?

enum'的?


I have an enum that will look kind of like this:

private enum MyEnum
{
SomeValue = 0,
AnotherValue = 1,
ThirdValue = 2
}
I have an url that will pass in a value like this that I want to put
into that enum:

http://ABCSite/MyPage.aspx?MyParameter=SomeValue

I''d like to use the Request.QueryString to retrieve the MyParameter
value (which equals "SomeValue") and convert that to an enum of type
MyEnum. Is there a quick and easy way to do it, or am I going to have
to build a select case to check all potential values that could come
in?

解决方案




- Show quoted text -

I am not seeing a Parse function within either just the enum object,
my actual enum object or a variable I create with a type of my enum
object. Can you send me a link to review the Parse function for
enum''s?



- Show quoted text -

I am not seeing a Parse function within either just the enum object,
my actual enum object or a variable I create with a type of my enum
object. Can you send me a link to review the Parse function for
enum''s?


这篇关于将查询参数转换为枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 12:18
查看更多