Skip to content

Instantly share code, notes, and snippets.

@mrpmorris
Last active January 25, 2024 19:40
Show Gist options
  • Save mrpmorris/aea3525437f66b8236f07ff1d1f69458 to your computer and use it in GitHub Desktop.
Save mrpmorris/aea3525437f66b8236f07ff1d1f69458 to your computer and use it in GitHub Desktop.
Convert string of floats to floats
static readonly char[] ExtractFloatsTrimChars = new char[] { '[', ']', ' ' };
static float[] ExtractFloats(string input) =>
input
.Trim(ExtractFloatsTrimChars)
.Split(',')
.Select(float.Parse)
.ToArray();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment