• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Need help! Asp.net for array

Jgtdragon

Diamond Member
Guys,
I can't figure this one out.

This work:
<% string MainString = "domain test";
string [] Split = MainString.Split(new char [] {' '});
//SHOW RESULT
Response.Write(Split[1]);

%>

The output is "test".

This doesn't work.
<% string MainString = "Domain\test";
string [] Split = MainString.Split(new char [] {'\\'});
//SHOW RESULT
Response.Write(Split[1]);

%>

I can't get "test". I kept getting any error. Not working with backslash. Need backslash to work.🙁

Any help is greatly appreciated.
 
In your code, the Domain\test is interpreted as Domain<tab>est because you haven't escaped the \ character in that test string. If you used either @"Domain\test" or "Domain\\test" it should work. If you're getting this string from the Windows identity, you don't have to worry about escaping the \. It's already correctly part of the string.
 
Originally posted by: oog
In your code, the Domain\test is interpreted as Domain<tab>est because you haven't escaped the \ character in that test string. If you used either @"Domain\test" or "Domain\\test" it should work. If you're getting this string from the Windows identity, you don't have to worry about escaping the \. It's already correctly part of the string.

You are exactly right! Thanks!

 
Back
Top