Answered by:
Split string based on "\" not working

Question
-
Hi all,
My program is receiving two strings, one from object and another from text box. The string in the text box could be easily split according to need but same is not happening in case of string from object.
Here is the codestring test = "Happy\Days"; string[] temp1 = test.Split(@"\".ToCharArray(), StringSplitOptions.None); string[] temp2 = TextBox1.Text.ToString().Split(@"\".ToCharArray(), StringSplitOptions.None);
Could you guys help me out.
Thanks in Advance,
ArunWednesday, December 17, 2008 11:33 AM
Answers
-
Hi,
first of all, your object is string? or anything else..
and you missed @ at the following linestring test = "Happy\Days";
it should be otherwise C# will throw you the error.
string test = @"Happy\Days";
Prakash Subramani (MCAD)- Marked as answer by Arun Gopal Wednesday, December 17, 2008 12:11 PM
Wednesday, December 17, 2008 11:49 AM -
Prakash,
I understand the fact to use @ before string.
The string was raised erroneously due to malfunctioning of one of the modules. Now its working fine and giving string as "Happy\\Days".
Thanks for the help.
- Marked as answer by Arun Gopal Wednesday, December 17, 2008 12:11 PM
Wednesday, December 17, 2008 12:08 PM
All replies
-
Hi,
first of all, your object is string? or anything else..
and you missed @ at the following linestring test = "Happy\Days";
it should be otherwise C# will throw you the error.
string test = @"Happy\Days";
Prakash Subramani (MCAD)- Marked as answer by Arun Gopal Wednesday, December 17, 2008 12:11 PM
Wednesday, December 17, 2008 11:49 AM -
Prakash,
I understand the fact to use @ before string.
The string was raised erroneously due to malfunctioning of one of the modules. Now its working fine and giving string as "Happy\\Days".
Thanks for the help.
- Marked as answer by Arun Gopal Wednesday, December 17, 2008 12:11 PM
Wednesday, December 17, 2008 12:08 PM