如何转换类型' string'到'字符串[]'在c#?

时间:2015-03-10 19:36:01

标签: c# xna

我的代码有点问题,请帮忙:

         String[] Boe;

         Boe = new String[1]; <---- i think the error might also be here 
         BS = new Rectangle();
         for (int p = 0; p < 1; p++)
         {
           //some code have been taken out 

             Boe = "Yes"; <----- this is where the error is being displayed 
         }

1 个答案:

答案 0 :(得分:0)

您的代码存在的问题是您尝试将整个数组设置为一个简单的字符串。您必须访问数组的索引,然后为此位置指定一个字符串值。 向下看

 String[] Boe;
 Boe = new String[1]; <---- i think the error might also be here 
 BS = new Rectangle();
 for (int p = 0; p < 1; p++)
 {
   //some code have been taken out 

     Boe[p] = "Yes"; <----- this is where the error is being displayed 
 }

希望它可以帮到你!