2015/4/9 数据转换 数组 枚举 /C#学习笔记

using System;
class StudentHomeWork
{
    public enum Friends
    { 老大, 老二, 老三, 老四, 老五, 老六 };
    public static void Main()
    {
        Friends f1 = Friends.老大;
        Friends f2 = Friends.老二;
        Friends f3 = Friends.老三;
        Friends f4 = Friends.老四;
        string[] family = new string[6];
        family[0] = "大姨";
        family[1] = "二姨";
        family[2] = "三姨";
        family[3] = "小姨";
        Console.WriteLine("这是我的朋友圈:1.friends,2.classmate,3.family,4.coupling");
        Console.Write("请选择:");
        for (int j = 1; j <= 5; j++)
        {
            string s = Console.ReadLine();
            int n = int.Parse(s);
            switch (n)
            {
                case 1:
                    Console.WriteLine(f1.ToString() + "," + f2.ToString() + "," + f3.ToString() + "," + f4.ToString());
                    break;
                case 2:
                    Console.WriteLine("马森, 曹真, 张梦婷, 杨明珠, 崔雄");
                    break;
                case 3:
                    Console.WriteLine(family[0] + "," + family[1] + "," + family[2] + "," + family[3]);
                    break;
                case 4:
                    Console.WriteLine("小明, 小小明");
                    break;
                default:
                    Console.WriteLine("没有了");
                    break;
                    //int[] Array1 = new int[] { 1, 2, 3, 4 };
                    //for (int i = 0; i < Array1.Length; i++)
                    //{
                    //    Console.WriteLine(i);
                    //}
            }

        }
    }

}

枚举:

enum{元素1,元素2};

1.枚举是常量,不是变量,使用过程中不能再被赋值

2.枚举元素本身由系统定义了一个表示序号的数值。从0开始顺序定义为0,1,2...。

数组(一维):

定义一个数组:

int[]sz=new int[5];

int[]sz=new int[3]{1,2,3}

 

 

 

 


 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。