Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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# 如何将字符串添加到变量、方法、线程,。。。名字_C#_Variables_Visual Studio 2012_Code Behind_Names - Fatal编程技术网

C# 如何将字符串添加到变量、方法、线程,。。。名字

C# 如何将字符串添加到变量、方法、线程,。。。名字,c#,variables,visual-studio-2012,code-behind,names,C#,Variables,Visual Studio 2012,Code Behind,Names,下面是一个简单的例子: int Parallel_Count = int.Parse(nudParallelCount.Text); for (int i = 1; i <= Parallel_Count; i++) { Thread string.Format("Thread_{0}", i) = new Thread(new ThreadStart(string.Format("Thread_{0}_Inside&q

下面是一个简单的例子:

    int Parallel_Count = int.Parse(nudParallelCount.Text);
    for (int i = 1; i <= Parallel_Count; i++)
    {
        Thread string.Format("Thread_{0}", i) = new Thread(new ThreadStart(string.Format("Thread_{0}_Inside", i) ));
        string.Format("Thread_{0}", i).Start();
    }

您正在寻找一个容器,如a或a。在进入线程之前,请确保您理解这些结构,因为它们是非常基本的构造,而线程是非常困难的

int Parallel_Count = int.Parse(nudParallelCount.Text);

Thread[] threads = new Thread[Parallel_Count];

for (int i = 0; i < Parallel_Count; i++)
{
    threads[i] = new Thread(/*fill thread start here*/);
    threads[i].Start();
}
int Parallel\u Count=int.Parse(nudParallelCount.Text);
线程[]线程=新线程[并行计数];
对于(int i=0;i
我在我的代码中多次看到这个问题,我很想知道解决方案是什么-如果你解决了我的问题,我可以使用一个条目而不是30个条目。你不能这样做,你需要一个
列表
数组
数据结构,即使是一本
字典
,如果你愿意的话。那么你能用with List或Array重写我的coedes吗?嗨,我怎么能用Array或List呢?你能给我一些密码吗?@MoonLight用密码更新了答案。容器是一个基本的概念,你应该花一些时间在它上面,可能在你继续线程之前使用一本好书或教程。亲爱的先生,我真的知道数组是什么!您绕过了我问题的重要部分(/*填充线程从这里开始*/)。这是什么意思?看,这与数组无关。我是否应该将这些方法放入数组中(这是一个解决方案)?如果您真的有不同的方法,则无法将其全部键入。但是问问自己,输入并行计数的用户是如何知道编译了多少函数的?也许您可以有一个函数,它根据线程的数量获取参数?亲爱的先生,谢谢您的阅读和帮助,我尊重您的建议。但是我的工作太难了,也许你应该花点时间在上面,也许在你继续学习之前使用一本好书或教程。顺便说一下,我有30个线程,我知道我在做什么。此外,这个问题与线程无关。正如我所说,我们可以看到关于变量名的相同问题。。。
int Parallel_Count = int.Parse(nudParallelCount.Text);

Thread[] threads = new Thread[Parallel_Count];

for (int i = 0; i < Parallel_Count; i++)
{
    threads[i] = new Thread(/*fill thread start here*/);
    threads[i].Start();
}