Table of Contents

Class StringExtensions

Namespace
WhatIsHeDoing.Core.Extensions
Assembly
WhatIsHeDoing.Core.dll

Provides extension methods for the string class.

public static class StringExtensions
Inheritance
StringExtensions
Inherited Members

Methods

AsCurrency(string)

Formats a string as a currency from the current globalisation.

public static string AsCurrency(this string source)

Parameters

source string

To parse

Returns

string

Formatted string or original if not a decimal

IsTrue(string)

Determines whether this string can be converted to a boolean and that value is true.

public static bool IsTrue(this string value)

Parameters

value string

To test

Returns

bool

true if the value is a boolean and true, or false

Parse<TResult>(string)

Invoke a Parse method from the TResult type on the value.

public static TResult Parse<TResult>(this string value)

Parameters

value string

To parse

Returns

TResult

Parsed value

Type Parameters

TResult

Containing the parse method

Exceptions

TypeLoadException

Thrown if TResult does not have a Parse method.

ToBytes(string)

Converts a string representation of a byte array

  • comma-separated values - to an actual byte array.
public static byte[] ToBytes(this string source)

Parameters

source string

To convert

Returns

byte[]

Bytes

Remarks

Leaves the underlying code to throw on error!

TryParse<TResult>(string, out TResult)

Tries to invoke a Parse method from the TResult type on the value.

public static bool TryParse<TResult>(this string value, out TResult result)

Parameters

value string

To parse

result TResult

Parsed value or default on failure

Returns

bool

Success

Type Parameters

TResult

Containing the parse method