+ 2

how to get first word of string in c#

5th Oct 2020, 9:10 AM
ramandeep kaur
7 Réponses
+ 4
string s = 'Solo learn'; Substring(0,s.IndexOf(' ')) If the words are separated by spaces.
5th Oct 2020, 9:20 AM
C K
C K - avatar
+ 1
String[0]. Example: string s = "SoloLearn"; s[0] gets 'S'.
5th Oct 2020, 9:16 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 1
word not character
5th Oct 2020, 9:18 AM
ramandeep kaur
+ 1
Trim the sentence to eliminate whitespaces by using string::Trim method. Split the sentence into string array by using string::Trim method. Print the first element of the array. Use the subscript operator to refer the element by index. Remember that first element has index of zero. P.S. Tag C# rather than 'SoloLearn'.
5th Oct 2020, 9:19 AM
Ipang
+ 1
Use String.Split() can split the string. Example: string s = "Solo Learn"; string[] arr = s.Split(); arr[0] is "Solo".
5th Oct 2020, 9:20 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 1
thank you very much
5th Oct 2020, 9:33 AM
ramandeep kaur
0
regex probably work..probably there are other better method though
5th Oct 2020, 9:21 AM
durian
durian - avatar