Declare Class List
public class TypeData
{
public string Times {get;set;}
}
Write Down Main Function inside Console Application
void Main()
{
List<TypeData> data = new List<TypeData>();
data.Add(new TypeData {Times = "01:00 PM"});
data.Add(new TypeData {Times = "02:00 PM"});
data.Add(new TypeData {Times = "03:00 PM"});
data.Add(new TypeData {Times = "04:00 PM"});
data.Add(new TypeData {Times = "05:00 PM"});
data.Add(new TypeData {Times = "06:00 PM"});
data.Add(new TypeData {Times = "07:00 PM"});
data.Add(new TypeData {Times = "08:00 PM"});
data.Add(new TypeData {Times = "09:00 PM"});
data.Add(new TypeData {Times = "10:00 PM"});
data.Add(new TypeData {Times = "11:00 PM"});
data.Add(new TypeData {Times = "12:00 PM"});
data.Add(new TypeData {Times = "01:00 AM"});
data.Add(new TypeData {Times = "02:00 AM"});
data.Add(new TypeData {Times = "03:00 AM"});
data.Add(new TypeData {Times = "04:00 AM"});
data.Add(new TypeData {Times = "05:00 AM"});
data.Add(new TypeData {Times = "06:00 AM"});
data.Add(new TypeData {Times = "07:00 AM"});
data.Add(new TypeData {Times = "08:00 AM"});
data.Add(new TypeData {Times = "09:00 AM"});
data.Add(new TypeData {Times = "10:00 AM"});
data.Add(new TypeData {Times = "11:00 AM"});
data.Add(new TypeData {Times = "12:00 AM"});
//data.Dump();
var datafinal_AM = data.Where(x=>x.Times.Contains("AM")).ToList();
var datafinal_PM = data.Where(x=>x.Times.Contains("PM")).ToList();
List<TypeData> finalR = new List<TypeData>();
foreach(var rows in datafinal_AM)
{
finalR.Add(new TypeData {Times = rows.Times});
}
foreach(var rows in datafinal_PM)
{
finalR.Add(new TypeData {Times = rows.Times});
}
}
Output :-