
@Kumarkrishna184, in addition to what Sheo Sir replied, I would like to add some more usage of ToList()
a) It helps to convert an anonymous type to a collection
b) If we want to add new objects to a named collection e.g
dt.AsEnumerable().Select(dr=>dr[0]).Tolist() .Foreach(i=>lst.Add(i));
where
dt is a
Datatable ,
dr is the
datarows and
lst is a
string collection . In this example the Tolist() is converting the datarows to a generic types and adding those to the list of strings.
c) Converts an IQuerable to IEnumerable
But in your example
var dinfo=obj.depts.ToList(); I don't think that .toList() conversion is needed as obj.depts is already a collection and without .ToList() also it will work.
hope that helps
--
Thanks & Regards,
RNA Team
Kumarkrishna184, if this helps please login to Mark As Answer. | Alert Moderator