Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,104 questions

40,777 answers

573 users

How to print list values in C#

2 Answers

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

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> list = new List<int>();
            list.Add(14);
            list.Add(87);
            list.Add(94);
            list.Add(199);

            foreach (int n in list) {
                Console.WriteLine(n);
            }
        }
    }
}


/*
run:
      
14
87
94
199
  
*/

 





answered Aug 3, 2018 by avibootz
0 votes
using System;
using System.Collections.Generic;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> list = new List<int>(new int[] { 34, 12, 98 , 99});

            for (int i = 0; i < list.Count; i++) {
                Console.WriteLine($"{i} = {list[i]}");
            }
        }
    }
}


/*
run:
      
0 = 34
1 = 12
2 = 98
3 = 99
  
*/

 





answered Aug 3, 2018 by avibootz

Related questions

1 answer 81 views
2 answers 35 views
35 views asked Feb 1, 2023 by avibootz
1 answer 49 views
1 answer 51 views
2 answers 114 views
...