the following snippet get the current user lgged into Sharepoint and displays his/her Name, Login name, Email and all the groups he/she belongs to.
try {
SPWeb web = SPControl.GetContextWeb(Context);
SPUser sUser = web.CurrentUser;
string str = "Name:" + sUser.Name + "<BR>";
str +="Login Name :" + sUser.LoginName + "<BR>";
str +="Email:" + sUser.Email + "<BR>";
str +="Groups:" + sUser.Groups.Count + "<BR>";
foreach (SPGroup grp in sUser.Groups)
{
str +=" * " + grp.Name + " total Members:" + grp.Users.Count + "<BR>";
}
catch (Exception ex)
{
messagebox.show("No Current User" );
}