Created
May 19, 2015 13:36
-
-
Save miguelangelgonzalez/a0b1273f017bf77ab950 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Common.Extensions | |
{ | |
public static class StringExtensions | |
{ | |
public static T AsEnum<T>(this string enumName) | |
{ | |
return (T)Enum.Parse(typeof(T), enumName, true); | |
} | |
public static long AsLong(this string text) | |
{ | |
return long.Parse(text); | |
} | |
public static bool AsBool(this string text) | |
{ | |
return bool.Parse(text); | |
} | |
public static decimal AsDecimal(this string text) | |
{ | |
return decimal.Parse(text); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment