static bool Contains( T value, T flag )
static bool Contains( string source, string toCheck, System.StringComparison comp )

robot_2Generated
code_blocksInput

Description

The Contains method is a static extension method provided by the SandboxSystemExtensions class. It checks if a specified value contains a particular flag. This method is generic and can be used with any type T that supports bitwise operations.

Usage

To use the Contains method, ensure that the type T supports bitwise operations, such as enums with the Flags attribute or integral types. The method will return true if the value contains the flag, otherwise it returns false.

Example

// Example usage of the Contains method

// Define an enum with Flags attribute
[Flags]
enum Permissions
{
    None = 0,
    Read = 1,
    Write = 2,
    Execute = 4
}

// Check if a permission set contains a specific permission
Permissions userPermissions = Permissions.Read | Permissions.Write;

bool hasWritePermission = SandboxSystemExtensions.Contains(userPermissions, Permissions.Write);
// hasWritePermission will be true

bool hasExecutePermission = SandboxSystemExtensions.Contains(userPermissions, Permissions.Execute);
// hasExecutePermission will be false