You can remove a user by its LoginName of by its internal UserId from a specified group.
Here is an example of both
Remove by UserId -
Method 1 –
web.AllowUnsafeUpdates = true;
SPGroupCollection collGroups = web.SiteGroups;
SPUserCollection usercoll = siteobj.RootWeb.SiteUsers;
int ID = oWeb.Users[UserName].ID;
usercoll.RemoveByID(ID);
web.Update();
web.AllowUnsafeUpdates = false;
Method 2 –
web.AllowUnsafeUpdates = true;
SPGroupCollection collGroups = web.SiteGroups;
SPUserCollection usercoll = siteobj.RootWeb.SiteUsers;
String LoginID = web.CurrentUser.LoginName;
usercoll.Remove(LoginID);
web.Update();
web.AllowUnsafeUpdates = false;