I have the following code.
public IEnumerable<int> BillLevel { get; set; }
I want to add values like this
BillLevel = [1, 2, 3, 4, 5],
What is the right syntax to assign an array of int to this list?
I have the following code.
public IEnumerable<int> BillLevel { get; set; }
I want to add values like this
BillLevel = [1, 2, 3, 4, 5],
What is the right syntax to assign an array of int to this list?
IEnumerable is an Interface so first you need to declare it with a class which implements IEnumerable like List and then simply add to list.
public IEnumerable<int> BillLevel { get; set; }
BillLevel = new List<int>();
BillLevel.AddRange(new int[]{1, 2, 3, 4, 5});
Or you can Add the numbers in declaration
BillLevel = new List<int>(){1, 2, 3, 4, 5};
You must to pass the reference of a class which implement IEnumerable Interface. Such as List Class implement this interface so you can pass the instance of List of int into this
public IEnumerable<int> BillLevel { get; set; }
BillLevel = new List<int>(){1,2,3,4,5};