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
sourcestringTo 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
valuestringTo test
Returns
- bool
trueif the value is a boolean and true, orfalse
Parse<TResult>(string)
Invoke a Parse method from the TResult type on the value.
public static TResult Parse<TResult>(this string value)
Parameters
valuestringTo parse
Returns
- TResult
Parsed value
Type Parameters
TResultContaining 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
sourcestringTo 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
valuestringTo parse
resultTResultParsed value or default on failure
Returns
- bool
Success
Type Parameters
TResultContaining the parse method