C#程序使用for循环遍历字符串数组
创建一个字符串数组-
string[] str = new string[] {
"Videos",
"Tutorials",
"Tools",
"InterviewQA"
};循环直到数组的长度-
for (int i = 0; i < str.Length; i++) {
string res = str[i];
Console.WriteLine(res);
}这是完整的代码-
示例
using System;
public class Demo {
public static void Main() {
string[] str = new string[] {
"Videos",
"Tutorials",
"Tools",
"InterviewQA"
};
Console.WriteLine("String Array...");
for (int i = 0; i < str.Length; i++) {
string res = str[i];
Console.WriteLine(res);
}
}
}输出结果
String Array... Videos Tutorials Tools InterviewQA
热门推荐
10 小侄过生日祝福语简短
11 小店营业的祝福语简短
12 担任老师的祝福语简短
13 饮料吧台祝福语简短大气
14 公司新春搞笑祝福语简短
15 高情商敬酒祝福语简短
16 婚礼祝福语新郎妹妹简短
17 教师答辩通过祝福语简短
18 生女孩红包简短祝福语