Table of Contents

Class LikeComparesExtensions

Namespace
Ecng.ComponentModel
Assembly
Ecng.ComponentModel.dll

Provides extension methods for comparing string values using a specified comparison operator.

public static class LikeComparesExtensions
Inheritance
LikeComparesExtensions
Inherited Members

Methods

Like(string, string, ComparisonOperator?)

Determines if the specified string value matches a pattern based on the provided comparison operator.

public static bool Like(this string value, string like, ComparisonOperator? likeCompare)

Parameters

value string

The string value to evaluate.

like string

The pattern to compare against.

likeCompare ComparisonOperator?

The comparison operator to use for the evaluation.

Returns

bool

True if the value satisfies the comparison; otherwise, false.

Exceptions

ArgumentNullException

Thrown when value is null.

ArgumentOutOfRangeException

Thrown when the comparison operator is not supported.

ToExpression(string, ComparisonOperator?)

Converts a pattern into an expression according to the specified comparison operator.

public static string ToExpression(this string like, ComparisonOperator? likeCompare = null)

Parameters

like string

The pattern to convert.

likeCompare ComparisonOperator?

The comparison operator that determines how the expression is formed. Defaults to ComparisonOperator.In if null.

Returns

string

A string expression representing the pattern.

Exceptions

ArgumentNullException

Thrown when like is empty.

NotSupportedException

Thrown when the NotEqual operator is used.

ArgumentOutOfRangeException

Thrown when the comparison operator is not supported.