-3

I want to shorten the code and add multiple items to list at once, I get error.

"No overload method Add taking 2 arguments"

The list has some items added and i want to add new ones

IList

public IList<SelectListItem> Cmsentities { get; set; }

method

Cmsentities.Add(
            new SelectListItem
            {
                Value = "publish",
                Text = "nur veröffentlichte"
            },
            new SelectListItem
            {
                Value = "nopublish",
                Text = "nur nicht veröffentlichte"
            });
Amir Dora.
  • 2,831
  • 4
  • 40
  • 61

1 Answers1

0

In addition to SelvaS's comment, you can also use List.AddRange(IEnumerable) Method if Cmsentities is already instantiated.

it'd look like

Cmsentities.AddRange(new List<SelectListItem> {new SelectListItem(), new SelectListItem()})
bronzeson
  • 71
  • 1
  • 8