AE+C#开发

namespace ZMJ
{
    public class Keyword
    {
        public static string a;
    }
}
如果a有多个值,怎么通过循环赋给其相应的值呢。比如循环为:
            foreach (var c in toc.role)
            {
                if (c == "我")
                {
                    a="a1";
                }
                else if (c == "你")
                {
                    a="a2";

                }
                else 
                {
                    a="a3";

                }
 
怎么将循环体加入最上面那个Keyword类中呢
已邀请:

嘎嘎叫 - 嘎嘎叫

赞同来自:

namespace ZMJ
{
    public class Keyword
    {
        public static string a()
       {
          foreach (var c in toc.role)
            {
                if (c == "我")
                {
                    a="a1";
                    return a;
                }
                else if (c == "你")
                {
                    a="a2";
                   return a;
                }
                else 
                {
                    a="a3";
                   return a;
                }
       }
    }
}
调用
keyword.a();

要回复问题请先登录注册