New course! Every coder should learn Generative AI!
Try a free lesson0
C#
int b=0; string a = textBox.Text.Trim(); string reversed= new string (a.Reverse().ToArray()); b=reversed.Length; why i can not Split(' - ') on string reversed! can you tell me ?
6 Answers
+ 1
You are welcome. Keep asking questions.
0
You can but the are a few things you should know about.
See in this code.
https://code.sololearn.com/cw0WMbX9Lx9Y/#cs
split returns an array of strings
string [] reversed_array;
reversed_array = reversed.Split('-');
split only allows one character reversed.Split('-'); instead of reversed.Split(' - '); (no space allowed, the are seen as characters.)
If you split string "a" you do not split string "reversed" so be carefull which string you are going to split
Does the textBox hold a string with a "-" in it.
please change you title to something more descriptive like "why i can not Split(' - ') on string reversed!", you a going to get a lot more answers if you question title is descriptive.
Hope this helps
0
Can you show me use with character Array .please !
0
It is a string array. An array of strings.
See how to use it, on the following pages.
https://www.dotnetperls.com/split
https://www.dotnetperls.com/array
I updated the code and put some more use of the string array in it.
https://code.sololearn.com/cw0WMbX9Lx9Y
0
Thanks sir ,,,:-)
0
I will try ,