In case you know exactly that department names is either "IT" or "NONIT", and the result should be single data, you can get the expected output without grouping :
var result2 = new
{
IT = (from dynamic stud in pairs where stud.dept == "IT" select stud).Count(),
NONIT = (from dynamic stud in pairs where stud.dept == "NONIT" select stud).Count()
};
Console.WriteLine(result.IT + "," + result.NONIT);
or if you favor grouping, I suggest to convert query result to dictionary to easily lookup count by department name :
var query = (from dynamic stud in pairs
group stud by stud.dept
into grps
select
new
{
Dept = grps.Key,
Count = grps.Count()
}).ToDictionary(o => o.Dept, o => o.Count);
Console.WriteLine(string.Format("result : {0}", query["IT"] + "," + query["NONIT"]));
If none of above suits your requirement, please update the question to explain more about what you're trying to achieve exactly.