How to print list with while loop in C#

1 Answer

0 votes
using System;
using System.Collections.Generic;

class Program
{
    static void Main() {
        List<string> lst = new List<string>() {"c#", "c", "c++", "c#", "java", "python"};

        var i = 0;
        while(i < lst.Count) {
            Console.WriteLine(lst[i]);
            i++;
        }
    }
}
 
 
 
 
/*
run:
 
c#
c
c++
c#
java
python
 
*/

 



answered Nov 14, 2021 by avibootz

Related questions

1 answer 294 views
294 views asked Nov 14, 2021 by avibootz
1 answer 195 views
1 answer 88 views
1 answer 113 views
113 views asked Oct 11, 2024 by avibootz
1 answer 225 views
1 answer 134 views
134 views asked Jan 14, 2024 by avibootz
...