我是C#的新手.我试图循环一个短数组,其中数组中的字符串元素放在网站搜索的末尾.代码:
int n = 1;
string[] s = {"firstitem","seconditem","thirditem"}
int x = s.Max(); // note, from my research this should return the maximum value in the array, but this is the first error
x = x + 1
while (n < x)
{
System.Diagnostics.Process.Start("www.website.com/" + b[0]);
b[]++; // this also generates an error "identifier expected"
}
Run Code Online (Sandbox Code Playgroud)
我的编码,逻辑或两者都是错的.根据我读过的内容,我应该能够在数组中获取最大值(作为int),然后添加到数组值,同时WHILE循环在网站末尾添加数组中的每个值(然后停止).请注意,在第一个错误上,我尝试使用不同的编码方式,如下所示:
int x = Convert.ToInt32(s.Max);
Run Code Online (Sandbox Code Playgroud)
但是,它会产生过载错误.如果我正确读取内容,MAX应该在序列中找到最大值.
foreach(var str in s)
{
System.Diagnostics.Process.Start("www.website.com/" + str);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3616 次 |
| 最近记录: |