สร้างอาร์เรย์สตริง −
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