Answers for "c list add element"

C#
3

c list add element

// Create a list  
List<string> AuthorList = new List<string>();  
  
// Add items using Add method   
AuthorList.Add("Mahesh Chand");
Posted by: Guest on June-26-2020
0

c list add element

using System;
using System.Collections.Generic;
 
class Program {
    static void Main(string[] args) {
        //empty list
        List<int> nums = new List<int>();
 
        //add elements to list
        nums.Add(63);
        nums.Add(58);
        nums.Add(47);
         
        //print list
        foreach (int num in nums) {
            Console.WriteLine(num);
        }
    }
}
Run the above C# program. The three items shall be added to the list.

Output

63
58
47
Posted by: Guest on May-15-2021

C# Answers by Framework

Browse Popular Code Answers by Language