This is my code: -
List<JObject> students =[{"id":"101","name":"one","parent_id":"1"},{"id":"102","name":"two","parent_id":"2"},{"id":"103","name":"three"},{"id":"104","name":"four"}];
I tried the following code using Linq but did not work
List<JObject> newStudents = students.Where(x => x.Property("parent_id").ToString() == null).ToList();
List<JObject> existedStudents = students.Where(x => x.Property("parent_id").ToString() != null).ToList();
The above list contains 4 objects, the first two objects contain the parent_idkey, the next two objects do not contain. How the parent_idkey existed and did not exist in the C # list.
source
share