2011-01-25 50 views
2

逃離反斜槓我有以下字符串在與string.replace

http://test.site.com\Content\Images\ProductImages\73\700-4aad-be94-e0b79982951f_0_Chrysanthemum__Product_Search.jpg 

我想更換string cleartext=imagePath.Replace("\","/");圖像控制,但反斜線導致一個問題 - 我怎能取代反斜線?

回答

3

反斜槓是啓動轉義序列的字符串中的特殊字符。您需要「轉義」\,因此您應該使用imagePath.replace(「\\」,「/」)

+1

替代方法:imagePath.Replace(@「\」,「/」); – 2011-01-26 09:53:52