How to insert " in a string
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: How to insert " in a string

  1. #1
    Join Date
    Jan 2002
    Posts
    10

    How to insert " in a string

    Hi,
    How would I insert a double quote <"> in a string in C#?
    I want to have a string which include a " inside......but I get compile error for below code:

    string st = "abc" + ""1"";

    Thanks if anyone can help.

  2. #2
    Join Date
    May 2003
    Location
    Germany
    Posts
    936

    Re: How to insert " in a string

    You have to escape the quotes.
    Code:
    string st = "abc" + "\"1\"";
    Useful or not? Rate my posting. Thanks.

  3. #3
    Join Date
    Apr 2005
    Posts
    576

    Re: How to insert " in a string

    Try searching the c# forum for similar threads and you will find what you need:

    http://www.codeguru.com/forum/showthread.php?t=367673

  4. #4
    Join Date
    Feb 2005
    Location
    Israel
    Posts
    1,475

    Re: How to insert " in a string

    Code:
    string st = @"abc""1"""
    Last edited by jhammer; December 16th, 2005 at 06:29 AM.

  5. #5
    Join Date
    Nov 2004
    Location
    India
    Posts
    63

    Re: How to insert " in a string

    Quote Originally Posted by jhammer
    Code:
    string st = @"abc""1"""
    Dont' forget a semi-colon at the end
    Sandeep
    http://www.sandeeprawat.com
    Code:
    Forget the language. Remember the logic.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center