dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: query about connection string in c#.net

  1. #1
    Join Date
    Nov 2006
    Posts
    22

    query about connection string in c#.net

    This is the code from C# in .net

    1. how are the below 2 codes different :-

    i) string connectionString ="data source=myserver;user id=myusername;password=mypassword;";

    ii) string connectionString = @"server = myserver;uid = myusername;password = mypassword;";


    2. and plz explain me the meaning of "@" in the ii) part.


    thanks and regards,
    vr

  2. #2
    Join Date
    Apr 2005
    Posts
    634
    (i) is regular string literal; it consists of zero or more characters enclosed in double quotes (i.e: "yo!")

    (ii) is a verbatim string literal; it consists of an @ character followed by a double-quote character, zero or more characters, and a closing double-quote character (i.e: @"yo!")

    the "yo" was a bad example, but consider you want to print a double quote in your string like this: yo"


    you can't do it with regular string literal because the double quote will treat as "closing double-quote".

    in order to print: yo", you need to:

    @"yo"""

    detail is here

  3. #3
    Join Date
    Nov 2006
    Posts
    22
    thanks
    vr

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles