Coree.NETStandard
  • API
Show / Hide Table of Contents
  • Coree.NETStandard.Abstractions.DependencySingleton
    • DependencySingleton<T>
    • IDependencySingleton
  • Coree.NETStandard.Abstractions.FluentBase
    • FluentBase
    • IFluentBase
  • Coree.NETStandard.Abstractions.InitializationService
    • InitializationDependentServices
    • InitializationService
  • Coree.NETStandard.Abstractions.ServiceFactory
    • ServiceFactory<T>
  • Coree.NETStandard.Abstractions.ServiceFactoryEx
    • ServiceFactoryEx<T>
    • ServiceFactoryEx<T, K, R, S, U, V, W, X, Y, Z>
    • ServiceFactoryEx<T, K>
    • ServiceFactoryEx<T, K, R>
    • ServiceFactoryEx<T, K, R, S>
    • ServiceFactoryEx<T, K, R, S, U>
    • ServiceFactoryEx<T, K, R, S, U, V>
    • ServiceFactoryEx<T, K, R, S, U, V, W>
    • ServiceFactoryEx<T, K, R, S, U, V, W, X>
    • ServiceFactoryEx<T, K, R, S, U, V, W, X, Y>
  • Coree.NETStandard.Classes.AsyncEventCollection
    • AsyncEventCollection<T>
    • AsyncEventCollection<T>.CustomEventDelegate
  • Coree.NETStandard.Classes.CommonDistinguishedNameBuilder
    • CommonDistinguishedNameBuilder
    • DistinguishedName
  • Coree.NETStandard.Classes.Criteria
    • CriteriaComparisonMethod
    • CriteriaEnumerableExtensions
    • CriteriaExpressionBuilder
    • CriteriaItem<TValue>
    • CriteriaItems
    • CriteriaOperator
    • CriteriaQueryableExtensions
  • Coree.NETStandard.Classes.HttpRequestService
    • ContentComposer
    • HttpRequestHeadersExtensions
    • HttpRequestService
    • HttpRequestServiceHandler
    • HttpRequestServiceUriExtensions
    • ServiceCollectionExtensions
    • TransactionRecord
  • Coree.NETStandard.Classes.Scheduler
    • Scheduler
    • Scheduler.TickerEventArgs
    • Scheduler.TickerEventDelegate
  • Coree.NETStandard.Classes.ThreadSafeCollection
    • ThreadSafeCollection<T>
  • Coree.NETStandard.Classes.ThreadSafeValue
    • ThreadSafeValue<T>
  • Coree.NETStandard.Classes.TimeOfDay
    • TimeOfDay
  • Coree.NETStandard.Extensions.Collections.Enumerable
    • CollectionsEnumerableExtensions
  • Coree.NETStandard.Extensions.Collections.List
    • CollectionsListExtensions
  • Coree.NETStandard.Extensions.Conversions.ByteArray
    • ConversionsByteArrayExtensions
  • Coree.NETStandard.Extensions.Conversions.HostApplicationBuilder
    • ConversionsHostApplicationBuilderExtensions
  • Coree.NETStandard.Extensions.Conversions.String
    • ConversionsStringExtensions
    • Encodings
  • Coree.NETStandard.Extensions.Conversions.Stringbuilder
    • ConversionsStringbuilderExtension
  • Coree.NETStandard.Extensions.Enums
    • EnumExtensions
  • Coree.NETStandard.Extensions.Http.HttpHeader
    • HttpHeadersExtensions
  • Coree.NETStandard.Extensions.Primitives.Bool
    • PrimitivesBoolExtensions
  • Coree.NETStandard.Extensions.Reflection.ServiceProvider
    • ReflectionServiceProviderExtensions
  • Coree.NETStandard.Extensions.ServiceCollection
    • ServiceCollectionExtensions
  • Coree.NETStandard.Extensions.Threading.CancellationToken
    • ThreadingCancellationTokenExtensions
  • Coree.NETStandard.Extensions.Utilities
    • DateTimeExtensions
  • Coree.NETStandard.Extensions.Validations.String
    • ValidationsStringExtensions
  • Coree.NETStandard.HostedServicesCollection
    • HostedServicesCollectionConfig<T>
    • IHostedServicesCollectionConfig<T>
    • ServiceCollectionExtensions
    • ServiceProviderExtensions
  • Coree.NETStandard.Serilog
    • ConditionalLevelSink
    • CustomTheme
    • LoggerSinkConfigurationExtensions
    • OutputTemplates
    • ServiceCollectionExtensions
    • SourceContextShortEnricher
  • Coree.NETStandard.Services.DebugManagement
    • DebugService
    • IDebugService
  • Coree.NETStandard.Services.DirectoryOperationsManagement
    • DirectoryOperationsService
    • IDirectoryOperationsService
  • Coree.NETStandard.Services.FileManagement
    • FileService
    • IFileService
  • Coree.NETStandard.Services.FileOperationsManagement
    • FileOperationsService
    • FileOperationsService.FileSystemEntry
    • FileOperationsService.FileSystemInformation
    • FileOperationsService.VerifiedCopyStatus
    • IFileOperationsService
  • Coree.NETStandard.Services.HashManagement
    • HashService
    • IHashService
  • Coree.NETStandard.Services.NetworkManagement
    • INetworkService
    • NetworkService
    • NetworkService.IpAdressInformation
    • NetworkService.NetworkInterfaceDetail
  • Coree.NETStandard.Services.ProcessManagement
    • IProcessService
    • ProcessRunExitCodeState
    • ProcessRunResult
    • ProcessService
  • Coree.NETStandard.Services.RuntimeInsightsManagement
    • IRuntimeInsightsService
    • RuntimeInsightsService
  • Coree.NETStandard.SpectreConsole
    • CommandAppExtensions
    • HostBuilderExtensions
    • ServiceCollectionExtensions
    • SpectreConsoleHostedService
    • SpectreConsoleHostedService.ExitCode
    • SpectreConsoleTypeRegistrar
    • SpectreConsoleTypeResolver
  • Coree.NETStandard.UnderConstruction
    • DbContextExtensions
    • HttpClientStatic
    • HttpClientStatic.HttpClientResponse
    • HttpClientStatic.XRate
    • HttpClientStatic.XRateGroup
    • HttpClientStatic.XRateItem
    • IScheduleProvider
    • IntervalScheduleProvider
    • LimitedHistory<T>
    • ScheduleCombiner
    • Scheduler
    • Scheduler.TickerEventArgs
    • Scheduler.TickerEventDelegate
    • Scheduler2
    • Scheduler2.TickerEventArgs
    • Scheduler2.TickerEventDelegate
    • Scheduler3
    • Scheduler3.TickerEventArgs
    • Scheduler3.TickerEventDelegate
    • SqlliteMemoryContext
    • SqlliteMemoryContext.UserDataDto
    • TimedEntry<T>
    • Timing
    • Timing.Ticker
    • Timing.Ticker.TickerEventArgs
    • Timing.TickerSync
    • WeekDayAtScheduleProvider
  • Coree.NETStandard.Utilities
    • EventSubscription
    • MainContext

Class ConversionsStringExtensions

Provides extension methods for string operations, enhancing the built-in string manipulation capabilities.

Inheritance
object
ConversionsStringExtensions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Coree.NETStandard.Extensions.Conversions.String
Assembly: Coree.NETStandard.dll
Syntax
public static class ConversionsStringExtensions

Methods

| Edit this page View Source

SplitWith(string?, char[], StringSplitOptions, bool)

Splits the input string by an array of characters, treating them as individual delimiters, with options to control the split operation. Offers the option to remove the delimiters from the resulting array.

Declaration
public static string[] SplitWith(this string? input, char[] delimiter, StringSplitOptions options = StringSplitOptions.None, bool removeDelimiters = true)
Parameters
Type Name Description
string input

The string to be split.

char[] delimiter

The array of characters joined to a string to use as delimiter

StringSplitOptions options

Specifies whether to omit empty or whitespace-only substrings from the resulting array.

bool removeDelimiters

When set to true, the delimiters themselves are excluded from the result array.

Returns
Type Description
string[]

An array of substrings that are delimited by the specified characters, optionally excluding the delimiters themselves.

Remarks

This method constructs a string from the character array and uses regular expressions for splitting, which may have performance implications for large strings or a large number of delimiters. When removeDelimiters is true, it filters out any substring that matches one of the delimiters exactly, after splitting.

| Edit this page View Source

SplitWith(string?, string, StringSplitOptions, bool)

Splits the input string by a specified string delimiter, with options to control the split operation. Offers the option to remove the delimiter from the resulting array.

Declaration
public static string[] SplitWith(this string? input, string delimiter, StringSplitOptions options = StringSplitOptions.None, bool removeDelimiters = true)
Parameters
Type Name Description
string input

The string to be split.

string delimiter

The string delimiter to split by.

StringSplitOptions options

Specifies whether to omit empty or whitespace-only substrings from the resulting array.

bool removeDelimiters

When set to true, the delimiter itself is excluded from the result array.

Returns
Type Description
string[]

An array of substrings that are delimited by the specified string, optionally excluding the delimiter itself.

Remarks

This method uses regular expressions to split the input string, which may have performance implications for large strings or a large number of delimiters. When removeDelimiters is true, it filters out the delimiter if it matches exactly, after splitting.

| Edit this page View Source

SplitWith(string?, string[], StringSplitOptions, bool)

Splits the input string by multiple string delimiters, with options to control the split operation. Offers the option to remove the delimiters from the resulting array.

Declaration
public static string[] SplitWith(this string? input, string[] delimiters, StringSplitOptions options = StringSplitOptions.None, bool removeDelimiters = true)
Parameters
Type Name Description
string input

The string to be split.

string[] delimiters

The array of string delimiters to split by.

StringSplitOptions options

Specifies whether to omit empty or whitespace-only substrings from the resulting array.

bool removeDelimiters

When set to false, the delimiters themselves are not excluded from the result array.

Returns
Type Description
string[]

An array of substrings that are delimited by any of the specified strings, optionally excluding the delimiters themselves.

Remarks

This method uses regular expressions to split the input string, which may have performance implications for large strings or a large number of delimiters. When removeDelimiters is true, it filters out any substring that matches one of the delimiters exactly, after splitting.

| Edit this page View Source

ToByteArray(string, Encodings)

Converts a string to a selected text encoding byte array.

Declaration
public static byte[] ToByteArray(this string String, Encodings encoding = Encodings.UTF8)
Parameters
Type Name Description
string String
Encodings encoding

The encoding type System.Text.Encoding

Returns
Type Description
byte[]
| Edit this page View Source

ToByteArray(string, int)

Converts a string to a byte array using a specified encoding.

Declaration
public static byte[] ToByteArray(this string String, int CodePage)
Parameters
Type Name Description
string String

The string to be converted.

int CodePage

The code page used for encoding.

Returns
Type Description
byte[]

A byte array resulting from encoding the string with the specified code page.

Exceptions
Type Condition
ArgumentException

Thrown when an invalid code page is provided or the string is null.

| Edit this page View Source

ToJsonDocument(string?)

Converts a JSON-formatted string to a JsonDocument.

Declaration
public static JsonDocument? ToJsonDocument(this string? jsonString)
Parameters
Type Name Description
string jsonString

The JSON string to convert.

Returns
Type Description
JsonDocument

A JsonDocument representation of the JSON string, or null if the string is null.

| Edit this page View Source

ToJsonNode(string?)

Converts a JSON-formatted string to a JsonNode.

Declaration
public static JsonNode? ToJsonNode(this string? jsonString)
Parameters
Type Name Description
string jsonString

The JSON string to convert.

Returns
Type Description
JsonNode

A JsonNode representation of the JSON string, or null if the string is null.

| Edit this page View Source

ToJsonPathResult(string?, string)

Evaluates a JSON Path expression on a JSON-formatted string and returns the result.

Declaration
public static PathResult? ToJsonPathResult(this string? jsonString, string jsonPath)
Parameters
Type Name Description
string jsonString

The JSON string to evaluate.

string jsonPath

The JSON Path expression to evaluate.

Returns
Type Description
PathResult

A PathResult containing the evaluation result, or null if the string is null.

| Edit this page View Source

ToJsonPathResultValues<T>(string?, string)

Evaluates a JSON Path expression on a JSON-formatted string and returns a list of values.

Declaration
public static List<T>? ToJsonPathResultValues<T>(this string? jsonString, string jsonPath)
Parameters
Type Name Description
string jsonString

The JSON string to evaluate.

string jsonPath

The JSON Path expression to evaluate.

Returns
Type Description
List<T>

A list of values matching the JSON Path expression, or null if the string or results are null.

Type Parameters
Name Description
T
| Edit this page View Source

ToShortUUID(string?)

Generates a UUID for the given string using MD5 hashing and returns it as a string without hyphens.

Declaration
public static string ToShortUUID(this string? input)
Parameters
Type Name Description
string input

The input string for which to generate the UUID. If null, an empty string is used.

Returns
Type Description
string

A string representation of the UUID generated from the input string, without hyphens.

Examples
string uuid = "your-long-string-here".ToShortUUID();
| Edit this page View Source

TrimSpecific(string, char, int, int)

Trims a specified number of characters from both the start and the end of the string.

Declaration
public static string TrimSpecific(this string input, char charToTrim, int countFromStart = 1, int countFromEnd = 1)
Parameters
Type Name Description
string input

The string to trim.

char charToTrim

The character to remove from the string.

int countFromStart

The number of characters to trim from the start, defaults to 1 if not specified.

int countFromEnd

The number of characters to trim from the end, defaults to 1 if not specified.

Returns
Type Description
string

The trimmed string, or the original string if it is null or empty.

Examples

string example = "aaaSampleStringaaa"; string trimmed = example.TrimSpecific('a'); // Equivalent to TrimSpecific('a', 1, 1) Console.WriteLine(trimmed); // Output: "aaSampleStringaa"

  • Edit this page
  • View Source
In this article
Back to top