<legend id='hTWP0'><style id='hTWP0'><dir id='hTWP0'><q id='hTWP0'></q></dir></style></legend>

<i id='hTWP0'><tr id='hTWP0'><dt id='hTWP0'><q id='hTWP0'><span id='hTWP0'><b id='hTWP0'><form id='hTWP0'><ins id='hTWP0'></ins><ul id='hTWP0'></ul><sub id='hTWP0'></sub></form><legend id='hTWP0'></legend><bdo id='hTWP0'><pre id='hTWP0'><center id='hTWP0'></center></pre></bdo></b><th id='hTWP0'></th></span></q></dt></tr></i><div id='hTWP0'><tfoot id='hTWP0'></tfoot><dl id='hTWP0'><fieldset id='hTWP0'></fieldset></dl></div>

  • <small id='hTWP0'></small><noframes id='hTWP0'>

  • <tfoot id='hTWP0'></tfoot>
          <bdo id='hTWP0'></bdo><ul id='hTWP0'></ul>
      1. C# - 错误“并非所有代码路径都返回值";以数组作为输出参数

        C# - Error quot;not all code paths return a valuequot; with an array as out parameter(C# - 错误“并非所有代码路径都返回值;以数组作为输出参数)
        <tfoot id='20vhi'></tfoot>
          <tbody id='20vhi'></tbody>
        <legend id='20vhi'><style id='20vhi'><dir id='20vhi'><q id='20vhi'></q></dir></style></legend>

          <small id='20vhi'></small><noframes id='20vhi'>

          • <bdo id='20vhi'></bdo><ul id='20vhi'></ul>

              <i id='20vhi'><tr id='20vhi'><dt id='20vhi'><q id='20vhi'><span id='20vhi'><b id='20vhi'><form id='20vhi'><ins id='20vhi'></ins><ul id='20vhi'></ul><sub id='20vhi'></sub></form><legend id='20vhi'></legend><bdo id='20vhi'><pre id='20vhi'><center id='20vhi'></center></pre></bdo></b><th id='20vhi'></th></span></q></dt></tr></i><div id='20vhi'><tfoot id='20vhi'></tfoot><dl id='20vhi'><fieldset id='20vhi'></fieldset></dl></div>

                • 本文介绍了C# - 错误“并非所有代码路径都返回值";以数组作为输出参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我目前有以下代码:

                  public int GetSeatInfoString(DisplayOptions choice, out string[] strSeatInfoStrings)

                  public int GetSeatInfoString(DisplayOptions choice, out string[] strSeatInfoStrings)

                      {
                          strSeatInfoStrings = null;
                          int count = GetNumOfSeats(choice);
                  
                          if ((count <= 0))
                              return 0;
                  
                          strSeatInfoStrings = new string[count];
                  
                          int i = 0;
                  
                          for (int index = 0; index <= m_totNumOfSeats - 1; index++)
                          {
                              if (string.IsNullOrEmpty(m_nameList[index]))
                                  strSeatInfoStrings[i++] =
                  

                  m_nameList[index].ToString();}

                  m_nameList[index].ToString(); }

                      }
                  

                  此代码产生错误...GetSeatInfoString.DisplayOptions, out string[])":并非所有代码路径都返回一个值.基本上,我希望在上述方法中执行的操作是循环一个数组和数组中包含字符串的任何值,我希望将它们添加到新数组中,strSeatInfoStrings 反过来可以从单独的类中调用,然后新的数组内容显示在列表框中.

                  This code produces an error of, "...GetSeatInfoString.DisplayOptions, out string[])': not all code paths return a value. Basically, what I am looking to do in the above method is to cycle through an array and for any values in the array that contain a string, I want these then adding to the new array, strSeatInfoStrings which in turn, can be called from a separate class and the new array content then displayed in a listbox.

                  关于如何纠正此问题的任何建议?

                  Any suggestions on how to rectify this?

                  提前致谢

                  推荐答案

                  可以在末尾加上 return strSeatInfoStrings.Length

                  You can add return strSeatInfoStrings.Length at the end

                  public int GetSeatInfoString(DisplayOptions choice, out string[] strSeatInfoStrings)
                  
                      {
                          strSeatInfoStrings = null;
                          int count = GetNumOfSeats(choice);
                  
                          if ((count <= 0))
                              return 0;
                  
                          strSeatInfoStrings = new string[count];
                  
                          int i = 0;
                  
                          for (int index = 0; index <= m_totNumOfSeats - 1; index++)
                          {
                              if (string.IsNullOrEmpty(m_nameList[index]))
                                  strSeatInfoStrings[i++] =
                  m_nameList[index].ToString(); }
                  
                      return strSeatInfoStrings.Length;
                  
                      }
                  

                  这篇关于C# - 错误“并非所有代码路径都返回值";以数组作为输出参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                  listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                  Cannot remove items from ListBox(无法从列表框中删除项目)
                  Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                  Drag and drop from list to canvas on windows phone with MVVM(使用 MVVM 在 Windows 手机上从列表拖放到画布)
                  Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)

                  <legend id='sLZOc'><style id='sLZOc'><dir id='sLZOc'><q id='sLZOc'></q></dir></style></legend>

                      <tfoot id='sLZOc'></tfoot>
                    1. <small id='sLZOc'></small><noframes id='sLZOc'>

                          <tbody id='sLZOc'></tbody>

                            <bdo id='sLZOc'></bdo><ul id='sLZOc'></ul>
                            <i id='sLZOc'><tr id='sLZOc'><dt id='sLZOc'><q id='sLZOc'><span id='sLZOc'><b id='sLZOc'><form id='sLZOc'><ins id='sLZOc'></ins><ul id='sLZOc'></ul><sub id='sLZOc'></sub></form><legend id='sLZOc'></legend><bdo id='sLZOc'><pre id='sLZOc'><center id='sLZOc'></center></pre></bdo></b><th id='sLZOc'></th></span></q></dt></tr></i><div id='sLZOc'><tfoot id='sLZOc'></tfoot><dl id='sLZOc'><fieldset id='sLZOc'></fieldset></dl></div>