Try this:
string s = "120, 130, 134, 138, 151, 3810";
var qry = s.Split(',')
.Select(a=>Convert.ToInt32(a.Trim()))
.GroupBy(a=>a)
.Select(grp=>new
{
value = grp.Key,
count = grp.Count()
});
Result:
value count
120 1
130 1
134 1
138 1
151 1
3810 1
[EDIT]
var qry = s.Split(',')
.Select(a=>Convert.ToInt32(a.Trim()))
.Distinct()
.Count();
[EDIT2]
According to OP comments:
List<string> s = new List<string>()
{
"120, 130, 134, 138, 151, 3810",
null,
"120, 130, 134, 202, 1151, 3810"
};
var qry = s.SelectMany(a=>(a ?? string.Empty).Split(new char[]{',', ' '}, StringSplitOptions.RemoveEmptyEntries))
.Distinct()
.Count();