I have the below code:
sDocType = pqReq.Substring(0, pqReq.IndexOf(@"\t"));
The string pqReq is like this: "CSTrlsEN\t001\t\\sgprt\Projects2\t001\tCSTrl". But even though I can clearly see the t\
in the string, pqReq.IndexOf(@"\t")
returns -1, so an error is thrown.
What's the correct way to do this? I don't want to split the string pqReq until later on in the code.
Use \\t
instead of \t
. The \t
is seen as a tab-character. sDocType = pqReq.Substring(0, pqReq.IndexOf(@"\t"));
I didn't notice the \t
being literal due to the @
. But is your input string a literal string? If not, place an @
before the value of pqReq
.
string pqReq = @"CSTrlsEN\t001\t\\sgprt\Projects2\t001\tCSTrl";
int i = pqReq.IndexOf(@"\t");
//i = 8
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments