ObjectExtensions.cs 486 B

1234567891011121314151617
  1. namespace Blazor.App.Common
  2. {
  3. public static class ObjectExtensions
  4. {
  5. /// <summary>
  6. /// Used to simplify and beautify casting an object to a type.
  7. /// </summary>
  8. /// <typeparam name="T">Type to be casted</typeparam>
  9. /// <param name="obj">Object to cast</param>
  10. /// <returns>Casted object</returns>
  11. public static T As<T>(this object obj)
  12. where T : class
  13. {
  14. return (T)obj;
  15. }
  16. }
  17. }