strgroupids = strgroupids.Remove(strgroupids.Length - 1);
MSDN:
String.Remove(Int32):
Deletes all the characters from this string beginning at a specified
position and continuing through the last position
strgroupids = strgroupids.Remove(strgroupids.Length - 1);
MSDN:
String.Remove(Int32):
Deletes all the characters from this string beginning at a specified
position and continuing through the last position