SPGroup.ContainsCurrentUser Property (Microsoft.SharePoint)

Switch View :
ScriptFree
SPGroup.ContainsCurrentUser Property

Gets a Boolean value that indicates whether the group contains the current user, included either through direct or indirect membership.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Syntax

Visual Basic (Declaration)
Public ReadOnly Property ContainsCurrentUser As Boolean
	Get
Visual Basic (Usage)
Dim instance As SPGroup
Dim value As Boolean

value = instance.ContainsCurrentUser

C#
public bool ContainsCurrentUser { get; }

Property Value

Type: System.Boolean
true if the group contains the current user; otherwise, false. For example, if the group object contains a domain group that contains the current user, this property returns true.
Remarks

The ExplicitlyContainsCurrentUser property does not consider indirect membership.

See Also

Reference

Community Content

VedMishra
Another code snippet
$0If you are looking for current user existence in a specific group on a Web Part Page:$0 $0$0 $0 Boolean b = SPContext.Current.Web.Groups["Your User Group"].ContainsCurrentUser;

Cagin Uludamar
Sample code
SPGroup spGroup = SPContext.Current.Site.RootWeb.SiteGroups["My User Group"];
bool b = spGroup.ContainsCurrentUser;