Loops

Loops = Repeat Without Copy-Paste

1. For: When you know count

for (int i = 1; i <= 3; i++) {
    Console.WriteLine($"OTP attempt #{i}");
}

2. Foreach: For lists

List<string> users = new() {"Kunal", "Riya"};
foreach (string user in users) {
    Console.WriteLine($"Hi {user}");
}

Quick Check ๐Ÿง 

Easy Q1: Which loop for iterating a List?

Comments on Loops (0)

No comments yet. Be the first to share your thoughts!