C# - What's the value of "str"? Why its length is 5? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

C# - What's the value of "str"? Why its length is 5?

var str = "-Solo--Learn-".Split('-'); Console.WriteLine(str); Console.WriteLine(str.Length);

30th Sep 2019, 1:36 PM
Paolo De Nictolis
Paolo De Nictolis - avatar
5 Answers
+ 6
Have a look at this sample code I made. https://code.sololearn.com/c2l7kyZud915 I think you are confused, because str is not a string
30th Sep 2019, 7:07 PM
sneeze
sneeze - avatar
+ 7
["", "Solo", "", "Learn", ""] Imagine the opposite operation: joining all the array elements with a "-".
30th Sep 2019, 1:39 PM
Schindlabua
Schindlabua - avatar
+ 2
Having a hard time wrapping my head around the split method :)
30th Sep 2019, 2:17 PM
HNNX 🐿
HNNX 🐿 - avatar
+ 2
Thanks sneeze !
1st Oct 2019, 6:35 AM
HNNX 🐿
HNNX 🐿 - avatar
+ 1
sneeze this is wonderful, thank you!
30th Sep 2019, 7:12 PM
Paolo De Nictolis
Paolo De Nictolis - avatar