Why not use string.Split to split the grid length string ?
See original GitHub issueWe need to parse the grid length string in the code below. But I think the easy way to do it is to use string.Split.
And I try to use string.Split
to replace this code and I found it can work and pass the unit test.
This is my code
public static IEnumerable<GridLength> ParseLengths(string s, CultureInfo culture)
{
foreach (var temp in s.Split(new []{',',' '}, StringSplitOptions.RemoveEmptyEntries))
{
yield return Parse(temp, culture);
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:19 (18 by maintainers)
Top Results From Across the Web
Java Split - wrong length
This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty...
Read more >How To Split String In C# (Basic & Advanced Tutorial)
The Split method is case-sensitive. For instance, splitting a string using “A” will not split on any occurrences of “a.”
Read more >String.Split Method (System)
Split is used to break a delimited string into substrings. You can use either a character array or a string array to specify...
Read more >CaseSplit - Maple Help
The LengthSplit command splits the string s into substrings of length len. An expression sequence of the substrings is returned. If len divides...
Read more >tf.strings.split | TensorFlow v2.13.0
Split each element of input based on sep and return a RaggedTensor containing the split tokens. Empty tokens are ignored. Example: tf.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@lindexi Definitely! We could probably eliminate all string allocations here, but I think we’ll need to wait for .NET Standard 2.1. Or provide alternate implementations for .NET Core and .NET Framework.
@Gillibald The real advantage from
Span
here would come from parsing APIs (e.g.Int32.TryParse(Span<char>)
) and that’s currently available only in .NET Core 2.1.