Euclidean Distance

StringExtensions.cs 542B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace EuclideanDistance
  5. {
  6. /// <summary>
  7. /// String extensions.
  8. /// </summary>
  9. public static class StringExtensions
  10. {
  11. /// <summary>
  12. /// Tos the point.
  13. /// </summary>
  14. /// <returns>
  15. /// The point.
  16. /// </returns>
  17. /// <param name='input'>
  18. /// Input.
  19. /// </param>
  20. public static IEnumerable<double> ToPoint(this string input)
  21. {
  22. return string.IsNullOrWhiteSpace(input)
  23. ? null
  24. : input.Split(new char[] { ',' }).Select(Double.Parse);
  25. }
  26. }
  27. }