使用 for 循环迭代字符串数组的 C# 程序
创建一个字符串数组——
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
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP