码迷,mamicode.com
首页 > 其他好文 > 详细

18._7章小结及任务实施

时间:2016-07-13 19:46:09      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _18._7章小结及任务实施
{
    class QQState
    {
        string[] qqState = {"在线","离线","Q我","隐身","忙碌" };
        private int getState(string stringState)
        { int i = 0;
           foreach(string State in qqState)
            {
                if (State == stringState) return i;
                i++;
            }
            return -1;
        }
       public int this[string state]
        {
            get { return getState(state); }

        }

    }

    class Program
    {
        static void Main(string[] args)
        {
            QQState qs = new QQState();
            Console.WriteLine("在线:{0}",qs["在线"]);
            Console.WriteLine("离线:{0}", qs["离线"]);
            Console.WriteLine("断线:{0}", qs["断线"]);
            Console.Read();
        }
    }
}

 

18._7章小结及任务实施

标签:

原文地址:http://www.cnblogs.com/zqyo2000z/p/5667289.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!