Results 1 to 3 of 3

Thread: 'Newline in constant'

  1. #1

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    'Newline in constant'

    Why am I getting this error because of this code:

    Code:
    int intStart = str.LastIndexOf("\");
    str is a string

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    int intStart = str.LastIndexOf(@"\");

    or

    int intStart = str.LastIndexOf("\\");

    the reason is because \ is a special character in c#
    so either you use \\ to tell the compiler that ur looking for that character, or you use @ sign to make the text between quotation a string.

  3. #3

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Thanks, a search on google turned up nothing but I did figure it out, lol. Guess I should have updated my post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width