Hi,
I have a string with undefined number of words.
I want to split this string in two parts: the last word alone and all the other words in another string.
How is that possible?
Thank you in advance
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Apr 4, 2012, 5:28 AM EDT
Pankajkumar PatelRank #181 · 13.4K reputationPosted Nov 20, 2021, 5:54 AM EST
Rijwan AnsariRank #82 · 24.2K reputationPosted Nov 20, 2021, 9:59 AM EST
Rijwan AnsariRank #82 · 24.2K reputationPosted Nov 20, 2021, 10:00 AM EST
Satya KarkiRank #78 · 24.6K reputationPosted Nov 20, 2021, 10:05 AM EST
SenthilkumarRank #387 · 6.5K reputationPosted Apr 4, 2012, 7:27 AM EDT
Simple logic will help you to get easily..
If it is helpful then mark it as correct answer.
Daril148 reputationPosted Nov 19, 2021, 2:49 AM EST
Use Split to split string on spaces.
By doing so it will separate all the words in it.
The output will be
You can also use String.Substring() and String.LastIndexof() instead of .Split