Hi ok... I'm new in this and got my hands full! I got a string like ;
string strReg = "HGT554GP - Red Ford Courier";
I want to remove all characters after the first space. I only want "HGT554GP".
Please any help will be appreciated.
Melger
Loading
Sam HobbsPosted Nov 19, 2010, 9:51 PM
Sam HobbsPosted Nov 20, 2010, 4:46 PM
There are at least two reasons there could be multiple posts considered to be answers. Multiple ways to do things is one but also there are times when there are multiple pieces to an answer.
I am not sure about closing a thread to all replies when an answer has been accepted. I have seen times when someone suggests a way to do something but it is not a good way yet the person accepts it as an answer. Often once they accept a solution, they are not interested in doing it another way. The problem is that we want people to use previous answers when they are available instead of posting the same question multiple times. So if a thread is closed when an answer is accepted that is not the best answer, then other developers in the future will be mislead.
Suthish NairPosted Nov 20, 2010, 12:04 PM
Mahesh ChandPosted Nov 20, 2010, 9:36 AM
You did not break anything.
Guys!
I am proposing to have multiple answers selected for a single question. The reason I say is, same problem can be solved in different ways.
But then issue may come, if another member replies the same. I guess we can live with it?
Alternatively, once an answer is accepted, we can CLOSE that thread. No more discussions about it.
What do you guys think? We will implement one of this right away and go live with it on Nov 27th.
Suthish NairPosted Nov 20, 2010, 1:09 AM
But i was wondering why i was getting Three accepted answer mails.. :-)
Answer disapproval notification mails also needed with reasons, will be an added advantage here.
Might this will get resolved in next release by C# Corner admins.
Melger,
Dont worry, keep posting your queries. Everyone here are ready to help you.
Good Day !
Sam HobbsPosted Nov 20, 2010, 12:21 AM
MelgerPosted Nov 20, 2010, 12:13 AM
Damit... first time I'm posting something and already broke it! Sorry guys, I think it was me selecting more than one checkbox! Suthish's code worked perfectly for me. Thanks again Suthish and sorry for breaking this thing!
Sam HobbsPosted Nov 19, 2010, 11:39 PM
Suthish NairPosted Nov 19, 2010, 11:28 PM
I got 3 different mails saying mine answer is accepted for this post.
But while viewing the thread its showing the accepted answer is not mine.
This might a bug happening here. Are the Administrators of site aware of this?
Suthish NairPosted Nov 19, 2010, 2:53 PM
If this post helped you, then tick the checkbox above "Do you like this Answer"
MelgerPosted Nov 19, 2010, 2:39 PM
Suthish NairPosted Nov 19, 2010, 2:09 PM
string strReg = "HGT554GP - Red Ford Courier".Split('-')[0].Trim();string strReg = "HGT554GP - Red Ford Courier".Split('-')[1].Trim();MelgerPosted Nov 19, 2010, 1:33 PM
string strReg = "HGT554GP - Red Ford Courier";
I want to remove all characters before the last space. I only want "Red Ford Courier".
Thanks again.
Melger
Suthish NairPosted Nov 19, 2010, 1:23 PM
Welcome to C# Corner.
string strReg = "HGT554GP - Red Ford Courier".Split(' ')[0].ToString().Trim();