开发者

show enum in view

开发者 https://www.devze.com 2022-12-24 12:05 出处:网络
i have enum 开发者_Python百科 public enum TypeImage { Img=0, Thumb=1 } i want in view show <%= TypeImage.Img %> -it shows \"img\" but not 0. what the problem?maybe something like:

i have enum

开发者_Python百科
 public enum TypeImage
{
    Img=0,
    Thumb=1
}

i want in view show <%= TypeImage.Img %> -it shows "img" but not 0. what the problem?


maybe something like:

<%= Convert.ToInt32(TypeImage.Img) %>


To show 0 you need to cast enum to integer:

<%= (int)TypeImage.Img %>
0

精彩评论

暂无评论...
验证码 换一张
取 消