C# | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

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 ?

15th Jul 2017, 10:14 AM
lee ratana
6 Answers
+ 1
You are welcome. Keep asking questions.
16th Jul 2017, 3:21 PM
sneeze
sneeze - avatar
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
15th Jul 2017, 6:46 PM
sneeze
sneeze - avatar
0
Can you show me use with character Array .please !
16th Jul 2017, 12:44 AM
lee ratana
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
16th Jul 2017, 2:49 PM
sneeze
sneeze - avatar
0
Thanks sir ,,,:-)
16th Jul 2017, 3:00 PM
lee ratana
0
I will try ,
16th Jul 2017, 3:00 PM
lee ratana