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 婶婶拜年祝福语大全简短