.NET Tip: String Literals Without Escape Characters Miami FL

Use @-quoted strings to avoid escape characters in your string literals.

Local Companies

Truelogic Software Solutions
(305) 407-9432
8345 NW 66th St.
Miami, FL
IBLESOFT INC
305.908.7957 EXT 100
7801 NW 37th Street
Doral, FL
Acl Computers Inc
(305) 826-5000
1711 W 38th Pl
Hialeah, FL
Game Rak Inc
(786) 517-1882
1790 W 49th St
Hialeah, FL
Software Development Solutions
305-274-2147
9745 SW 72nd St
Miami, FL
Home Care Software Solutions Inc
786-433-4700
9500 S Dadeland Blvd
Miami, FL
Alta Star Software Inc
305-279-8898
7700 N Kendall DR
Miami, FL
BlueClaw Group LLC
(305) 433-2006
1508 bay rd
miami beach, FL
TrueSoft
408-647-1434
911 Meridian Ave, Suite 201
Miami Beach, FL
Creative Technical Systems
(305) 512-2872
8181 NW 154th St
Hialeah, FL

provided by: 
Originally published at Internet.com


Today's tip is a very simple one, but if you are like me you will find yourself using it frequently. Do you have string literals that are filled with escape characters because they include characters that have a special meaning? One of the most common places you will find this is in file paths. If you don't want to have to worry about getting all of the backslashes correct, try using an @-quoted string instead. Say you have a variable like the following in your application: string AppDataFile = "C:\\Program Files\\My Application \\MyApp.dat";

This works fine, but can be hard to read and is more likely to be prone to errors if you do not escape all of the backslashes correctly. Another option, using @-quoted strings, removes the need to escape the backslashes. The @-quoted version of the above example looks like this: string AppDataFile = @"C:\Program Files\My Application \MyApp.dat";

The only changes are the addition of the @ sign before the opening quotation mark and the removal of the backslash to escape the other backslashes. This format matches the way you see file and directory paths displayed everywhere else in Windows. You can use @-quoted strings for more than paths, so take a look at your use of string literals and see where you can simplify you code and make it more readable.

About the Author

Jay Miller is a Software Engineer with Electronic Tracking Systems, a company dedicated to robbery prevention, apprehension, and recovery based in Carrollton, Texas. Jay has been working with .NET since the release of the first beta and is co-author of Learn Microsoft Visual Basic.Net In a Weekend. Jay can be reached via email at jmiller@sm-ets.com.

Author: Jay Miller

Read article at Internet.com site

Featured Local Company

Truelogic Software Solutions

3054079432
8345 NW 66th St.
Miami, FL
www.truelogicsoftware.com

Related Local Events
SCORE Business Counseling
Dates: 12/9/2009 - 12/9/2009
Location: The Chamber Office
Coral Springs, FL
View Details

Wake Up Coral Springs Breakfast!!
Dates: 12/15/2009 - 12/15/2009
Location: Marriott Heron Bay
Coral Springs, FL
View Details

Wednesday Evening Referral Group
Dates: 12/16/2009 - 12/16/2009
Location: WineStyles
Coral Springs, FL
View Details

Afternoon Chamber Referral Group Meeting
Dates: 1/21/2010 - 1/21/2010
Location: The Coral Springs Chamber Office
Coral Springs, FL
View Details

Wednesday Evening Referral Group
Dates: 2/3/2010 - 2/5/2010
Location: WineStyles
Coral Springs, FL
View Details