0
What is the output of this code and why?How does it work ?
var str = "-Solo--Learn-".Split('-'); Wrireline(str.Length); 2 4 5 9
2 Answers
+ 1
Please edit your question and specify the language (presumably C#)
Khachatur Melkonyan
Thank you for understanding.
The code output would be 5.
Explanation:
"-Solo--Learn-" is a string literal, which will be splitted using hyphen as the delimiter. The `Split` method of the string class will do the work. The result is presumably a string array containing parts of the string which are not hyphen.
{"", "Solo", "", "Learn", ""}
This are the array contents (result from splitting the string).
Hth, cmiiw
+ 1
Thank you