本文主要是介绍获取字符串每个字符并给予相应的赋值,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
business 值为: 11111、10111、00110、11001等
char [] charArray=business.ToCharArray();
string busines = string.Empty;
for (int i = 0; i < charArray.Length; i++)
{
if (charArray[0].ToString()=="1" && i == 0)
{
busines = "1. Fiber Producer<br/>";
}
if (charArray[1].ToString() == "1" && i == 1)
{
busines = busines + "2. Textile Manufacturer<br/>";
}
if (charArray[2].ToString() == "1" && i == 2)
{
busines = busines + "3. Supplier of Raw materials<br/>";
}
if (charArray[3].ToString() == "1" && i == 3)
{
busines = busines + "4. Terminal-User of Textiles<br/>";
}
if (charArray[4].ToString() == "1" && i == 4)
{
busines = busines + "5. Others<br/>";
}
}
MainBusiness.Text = busines;
这篇关于获取字符串每个字符并给予相应的赋值的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!