Skip to content

Instantly share code, notes, and snippets.

@miguelangelgonzalez
Created May 19, 2015 13:36
Show Gist options
  • Save miguelangelgonzalez/a0b1273f017bf77ab950 to your computer and use it in GitHub Desktop.
Save miguelangelgonzalez/a0b1273f017bf77ab950 to your computer and use it in GitHub Desktop.
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