• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

w

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

12月29日学习笔记,常量,枚举的使用

常量:能够设定程序中那些不会被修改的值。如果强行修改,就会报错。

如:class g

    {

        public const int gs = 100;

}

 

 

使用枚举来定义各种属性,先定义一个枚举,然后在枚举里设定各类值

如:// static void Main(string[] arge)

       // {

            //string[] color = new string[] {"red","black","white" };

            //Console.WriteLine("我要选择的颜色是{0}",color[0]);

 

          

       // }

        private enum color

        {

            red,black,white

        }

        static void Main(string[] arge)

        {

            Console.WriteLine("我要选择的颜色是{0}",color.red);

    }

 

注意:枚举的主体里不能定义属性和方法。

posted on 2009-12-30 05:14  wwweee  阅读(131)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3