Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WinForms如何在字符串数组中存储值(Properties.Settings.Default)_C#_Arrays_Winforms - Fatal编程技术网

C# WinForms如何在字符串数组中存储值(Properties.Settings.Default)

C# WinForms如何在字符串数组中存储值(Properties.Settings.Default),c#,arrays,winforms,C#,Arrays,Winforms,我想将一些值存储到我的设置变量中,我做了一些,但似乎不起作用 bool saveLevelSettings() { if (rightPanel.Controls.Count > 3) { for (int i = 4; i <= rightPanel.Controls.Count; i++) { for (int j

我想将一些值存储到我的设置变量中,我做了一些,但似乎不起作用

bool saveLevelSettings()
        {
            if (rightPanel.Controls.Count > 3)
            {
                for (int i = 4; i <= rightPanel.Controls.Count; i++)
                {
                    for (int j = 0; j <= 4; j++)
                    {
                        if (String.IsNullOrEmpty(rightPanel.Controls[i - 1].Controls[j].Text))
                        {
                            return false;
                        }

                        switch (j)
                        {
                            case 0:
                                Properties.Settings.Default.Levels[i - 4] = rightPanel.Controls[i - 1].Controls[j].Text;
                                break;
                            case 1:
                                Properties.Settings.Default.Sblinds[i - 4] = rightPanel.Controls[i - 1].Controls[j].Text;
                                break;
                            case 2:
                                Properties.Settings.Default.Bblinds[i - 4] = rightPanel.Controls[i - 1].Controls[j].Text;
                                break;
                            case 3:
                                Properties.Settings.Default.Antes[i - 4] = rightPanel.Controls[i - 1].Controls[j].Text;
                                break;
                            case 4:
                                Properties.Settings.Default.Timers[i - 4] = rightPanel.Controls[i - 1].Controls[j].Text;
                                break;
                        }
                    }
                }
                return true;
            }
            return false;
        }
bool savelSettings()
{
如果(rightPanel.Controls.Count>3)
{

对于(int i=4;i您可以先将其构建到一个数组中,并将其分配给设置变量。似乎骰子数组未初始化。请使用
StringCollection
而不是sting数组,并确保其在添加新字符串项之前不
null
,否则
new
首先将其分配给设置变量。非常欢迎。再见。您是请先将其构建到数组中,并将其分配给设置变量。似乎模具数组未初始化。请使用
StringCollection
而不是sting数组,并确保在向其添加新字符串项之前其不为
null
,否则
new
先将其初始化。非常欢迎。再见。