在c#中使用Enums的基本用法是什么 [英] What is the basic use of Enums in c#

查看:64
本文介绍了在c#中使用Enums的基本用法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,任何人都可以解释一下c#在枚举的基本用法是什么情况我们需要枚举



谢谢提前

Hi all can anyone explain me what is the basic use of enums in c# in what scenarios we need of enums

Thank's In advance

推荐答案

http://msdn.microsoft.com/en-us /library/sbbt4032.aspx [ ^ ]


枚举用于将类似数据组合在一起.........假设您要创建使用货币的程序,以便货币价值不断变化因此,如果你必须在程序中的太多地方使用货币并且你通过使用常量或其他东西来实现它,那么你可以在任何地方更改值都会遇到很大的问题所以你只需更改枚举范围中的值就可以在任何地方更改它在节目中...........









您可以从中获取更多详细信息这个链接



http:// msdn。 microsoft.com/en-us/library/sbbt4032.aspx [



问候,

Ahsan Naveed
enums are used to group similar data together.........suppose you want to create program in which you use currencies so value of currencies keep on changing so if you have to use currencies in too many places in a program and you do it by using constants or something else you can get in great problem for changing values everywhere so you just simply change the values in the enumeration scope and it gets changed everywhere in the program...........




you can get further details from this link

http://msdn.microsoft.com/en-us/library/sbbt4032.aspx[

Regards,
Ahsan Naveed


这篇关于在c#中使用Enums的基本用法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆