Reputation: 385
I have this model:
public class StationData
{
public int StationID{ get; set; }
public List<int> FileID { get; set; }
}
In my main page, I call a method that will return an object of type "StationData".
Now, what I want is to remove an item from the "List" where FileID = value;
Is that possible?
Upvotes: 1
Views: 1165
Reputation: 560
try this
var tempItem = data.FirstOrDefault(item => item.FileID.Any(field => field == 1));
if (tempItem != null)
data.Remove(tempItem);
O, sorry i misunderstood
StationData data = new StationData();
var tempItem = data.FileID.Where(item => item == value);
if(tempItem !=null)
{
var enumerable = tempItem.ToList();
foreach (var i in enumerable)
{
data.FileID.Remove(i);
}
}
Upvotes: 1