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 273 views
273 views asked Nov 14, 2021 by avibootz
1 answer 178 views
1 answer 82 views
1 answer 107 views
107 views asked Oct 11, 2024 by avibootz
1 answer 205 views
1 answer 119 views
119 views asked Jan 14, 2024 by avibootz
...