How to add List<> to a List<> in asp.net [duplicate] How to add List<> to a List<> in asp.net [duplicate] asp.net asp.net

How to add List<> to a List<> in asp.net [duplicate]


Use List.AddRange(collection As IEnumerable(Of T)) method.

It allows you to append at the end of your list another collection/list.

Example:

List<string> initialList = new List<string>();// Put whatever you want in the initial listList<string> listToAdd = new List<string>();// Put whatever you want in the second listinitialList.AddRange(listToAdd);


Try using list.AddRange(VTSWeb.GetDailyWorktimeViolations(VehicleID2));


  1. Use Concat or Union extension methods. You have to make sure that you have this declaration using System.Linq; in order to use LINQ extensions methods.

  2. Use the AddRange method.