为什么\\字符正在我的@串翻倍? [英] Why is \ character being doubled in my @ string?

查看:96
本文介绍了为什么\\字符正在我的@串翻倍?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var phone = @"^\+(?:[0-9] ?){6,14}[0-9]$";

手机也就那么等于 ^ \\\\ +(?:?[0-9]){} 6,14 [0-9] $

我想(我发现的例子似乎显示)@字符意味着要离开我的字符串我怎么有它。为什么会加倍\\以及如何阻止它?

I thought (and the examples I found seem to show) the @ character meant to leave my string how I have it. Why is it doubling the \ and how do I stop it?

推荐答案

在Visual Studio调试器的显示的它,好像它加倍,因为在C#\\将precede转义序列。别担心 - 你的字符串是不变的。

The visual studio debugger will show it as if it were doubled, since in C# a \ would precede an escape sequence. Don't worry - your string is unchanged.

这篇关于为什么\\字符正在我的@串翻倍?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆