New to Telerik UI for ASP.NET Core? Start a free 30-day trial

Extension methods for String.

Definition

Namespace:Kendo.Mvc.Extensions

Assembly:Kendo.Mvc.dll

Syntax:

C#
public static class StringExtensions

Inheritance: objectStringExtensions

Inherited Members object.GetType()object.MemberwiseClone()object.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()...

Methods

Converts the string to a title format by extracting the last segment and splitting PascalCase.

C#
public static string AsTitle(this string value)
Parameters:valuestring

The string to convert.

Returns:

string

The title-formatted string.

Escapes HTML entities in a string by adding backslashes before entity references.

C#
public static string EscapeHtmlEntities(this string html)
Parameters:htmlstring

The HTML string to escape.

Returns:

string

The escaped string.

Replaces the format item in a specified System.String with the text equivalent of the value of a corresponding System.Object instance in a specified array.

C#
public static string FormatWith(this string instance, params object[] args)
Parameters:instancestring

A string to format.

argsobject[]

An System.Object array containing zero or more objects to format.

Returns:

string

A copy of format in which the format items have been replaced by the System.String equivalent of the corresponding instances of System.Object in args.

Determines whether the string has a non-null and non-empty value.

C#
public static bool HasValue(this string value)
Parameters:valuestring

The string to check.

Returns:

bool

True if the string has a value; otherwise, false.

Determines whether this instance and another specified System.String object have the same value.

C#
public static bool IsCaseInsensitiveEqual(this string instance, string comparing)
Parameters:instancestring

The string to check equality.

comparingstring

The comparing with string.

Returns:

bool

true if the value of the comparing parameter is the same as this string; otherwise, false.

Determines whether this instance and another specified System.String object have the same value.

C#
public static bool IsCaseSensitiveEqual(this string instance, string comparing)
Parameters:instancestring

The string to check equality.

comparingstring

The comparing with string.

Returns:

bool

true if the value of the comparing parameter is the same as this string; otherwise, false.

Encodes a string for use in JavaScript, optionally adding quotes.

C#
public static string JavaScriptStringEncode(this string value, bool addDoubleQuotes, char quotes = '"')
Parameters:valuestring

The string to encode.

addDoubleQuotesbool

Whether to add quotes around the encoded string.

quoteschar

The quote character to use (default is double quote).

Returns:

string

The JavaScript-encoded string.

Encodes a string for use in JavaScript.

C#
public static string JavaScriptStringEncode(this string value)
Parameters:valuestring

The string to encode.

Returns:

string

The JavaScript-encoded string.

Converts a kebab-case string to PascalCase.

C#
public static string KebabCaseToPascalCase(this string value)
Parameters:valuestring

The kebab-case string.

Returns:

string

The PascalCase string.

Converts a PascalCase string to kebab-case (lowercase with hyphens).

C#
public static string PascalCaseToKebabCase(this string value)
Parameters:valuestring

The PascalCase string.

Returns:

string

The kebab-case string.

Removes all whitespace characters from the string.

C#
public static string RemoveWhiteSpace(this string instance)
Parameters:instancestring

The string to process.

Returns:

string

The string with all whitespace removed.

Splits a PascalCase string into words separated by spaces.

C#
public static string SplitPascalCase(this string value)
Parameters:valuestring

The PascalCase string.

Returns:

string

The string with spaces between words.

Converts the first character of the string to lowercase (camelCase).

C#
public static string ToCamelCase(this string instance)
Parameters:instancestring

The string to convert.

Returns:

string

The camelCase version of the string.

Converts the string to an enum value, or returns the default value if conversion fails.

C#
public static T ToEnum<T>(this string value, T defaultValue)
Parameters:valuestring

The string to convert.

defaultValueT

The default value to return if conversion fails.

Returns:

T

The enum value or the default value.