question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why not use string.Split to split the grid length string ?

See original GitHub issue

We 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.

https://github.com/AvaloniaUI/Avalonia/blob/35b29d8f2367fcc62775bc4de7d5f8a3802d8c07/src/Avalonia.Controls/GridLength.cs#L212

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:closed
  • Created 5 years ago
  • Comments:19 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
aelijcommented, Mar 18, 2019

@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.

0reactions
aelijcommented, Mar 18, 2019

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found