Re: New Line Constant Error!
From: Joakim Karlsson (jkarlsson_at_NOSPAMjkarlsson.com)
Date: 01/25/05
- Next message: Pickles The Cat: "Lock tables during SELECT"
- Previous message: Prem S: "Re: Security for "Program Files""
- In reply to: Chakkaradeep: "New Line Constant Error!"
- Next in thread: Bruce Wood: "Re: New Line Constant Error!"
- Reply: Bruce Wood: "Re: New Line Constant Error!"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 25 Jan 2005 21:08:44 +0100
Chakkaradeep wrote:
> Hi all,
>
> i have a string,
>
> str_old="E:\a\b\c.exe",
>
> and i want to change to
>
> str_new="E:\\a\\b\\c.exe".
>
This would work:
string str_old = @"E:\a\b\c.exe";
string str_new = str_old.Replace(@"\", @"\\");
> so now i use IndexOf() function to find the position of '\' , but it is
> throwing error that a new line constant is present.
>
> (i.e); int n=str_old.IndexOf('\'); //error here..new line constant
As you are using a character literal, the line should look like this:
int n = str_old.IndexOf('\\');
But as I stated earlier, you could just use String.Replace in this case.
Regards,
Joakim
- Next message: Pickles The Cat: "Lock tables during SELECT"
- Previous message: Prem S: "Re: Security for "Program Files""
- In reply to: Chakkaradeep: "New Line Constant Error!"
- Next in thread: Bruce Wood: "Re: New Line Constant Error!"
- Reply: Bruce Wood: "Re: New Line Constant Error!"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|