Hi sushma123,
The conditional operator requires that the return type be the same or an implicit conversion must exist from one type to the other.
The return types of both are of Anonymous type.
Both needs to be same Anonymous type the field names and type must be the same and must appear in the same order.
I am assuming that UserGroup and CompanyCodeConflict are of the same data type.
So you needed is to name the fields of the Anonymous type the same like below.
var conflictcomments = (item.Key == Constant.SB023)
? item.GroupBy(m => new
{
Code: m.UserGroup,
IGGConflict = m.IGGConflict
})
: item.GroupBy(m => new
{
Code:m.CompanyCodeConflict,
IGGConflict= m.IGGConflict
});