再给一个名字统一的名字 [英] give more then one name unified name

查看:62
本文介绍了再给一个名字统一的名字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个人都高!
我怎么能给多个名字统一的名字
例子
我有以下字符串:美国",德国",法国"
我想给他们起个名字:国家
当我比较输入单词和输入内容时,我会比较
如果(单词==国家)
{
做点事
}

High every one !
how can i give more than one name unified name
example
i have the following strings : "U.S" , "Germany" , "France"
and i want to give them name : country
when i compare incoming word to my input i would compare
if (word == country )
{
do some thing
}

推荐答案

您可以将国家/地区添加到数组或列表中,如果该单词匹配,则可以遍历该列表.例如代码:

You can add the countries to an array or to a list and then loop through that list if that word matches. For example code:

string[] arrCountries = new string[] { "U.S", "Germany", "France" };

foreach(string arrItem in arrCountries)
{
   if(arrItem == word)
   {
      //do something
   }
}



祝你好运



Good luck


这篇关于再给一个名字统一的名字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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