c list add element
// Create a list
List<string> AuthorList = new List<string>();
// Add items using Add method
AuthorList.Add("Mahesh Chand");
c list add element
// Create a list
List<string> AuthorList = new List<string>();
// Add items using Add method
AuthorList.Add("Mahesh Chand");
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
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us