You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
615 B

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. using System;
  2. namespace IPA.Utilities
  3. {
  4. /// <summary>
  5. /// A class providing various extension methods.
  6. /// </summary>
  7. public static class Extensions
  8. {
  9. /// <summary>
  10. /// Gets the default value for a given <see cref="Type"/>.
  11. /// </summary>
  12. /// <param name="type">the <see cref="Type"/> to get the default value for</param>
  13. /// <returns>the default value of <paramref name="type"/></returns>
  14. public static object GetDefault(this Type type)
  15. {
  16. return type.IsValueType ? Activator.CreateInstance(type) : null;
  17. }
  18. }
  19. }