GenericPrincipal.IsInRole Method (String)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Determines whether the current GenericPrincipal belongs to the specified role.

Namespace:   System.Security.Principal
Assembly:  mscorlib (in mscorlib.dll)

public override bool IsInRole(
	string role


Type: System.String

The name of the role for which to check membership.

Return Value

Type: System.Boolean

true if the current GenericPrincipal is a member of the specified role; otherwise, false.

The following code shows the use of the IsInRole method. This code example is part of a larger example provided for the GenericPrincipal class.

if (genericPrincipal.IsInRole("NetworkUser"))
    Console.WriteLine("User belongs to the NetworkUser role.");

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top