create List c#
using System.Collections.Generic
//type is your data type (Ej. int, string, double, bool...)
List newList = new List();
make a list c#
IList newList = new List(){1,2,3,4};
c# array to list
var intArray = new[] { 1, 2, 3, 4, 5 };
var list = new List(intArray);
decalre an int list mvc
List intList = new List();
c# list
// This will create a new list called 'nameOfList':
var nameOfList = new List
{
"value1",
"value2",
"value3"
};
c# list
using System;
using System.Collections.Generic;
namespace main {
class Program {
private static void Main(string[] args) {
// syntax: List name = new List();
List integerList = new List();
for (int i = 0; i < 10; i++) {
// add item to list
integerList.Add(i);
}
for (int i = 0; i < 10; i++) {
// print list item
Console.WriteLine(integerList[i]);
}
}
}
}
|