在变量命名中使用@作为前缀 [英] Using @ as prefix in variable naming

查看:126
本文介绍了在变量命名中使用@作为前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有疑问,使用@作为变量Name的前缀或方法参数名称是什么意思,如下所示。你可以看到我使用和不使用相同的变量名称,所以有什么区别。希望你们这将是一个基本的问题,我不知道其中的区别。



Hi all,

I have question what does it mean using @ as prefix for a variable Name or in a method parameter name as like below. as you can see i have used same variable name with and without @ so what was the difference. Hope for you guys it will be a basic question which i don't know the difference.

public static string ReplaceSpecialCharacters(this string @sText)
        {
            @sText.Replace("& lt; ", "<");
            @sText.Replace("& gt;", ">");
            sText.Replace("& amp;", "&");
            @sText.Replace("& quot;", "\"");
            sText.Replace("& apos;", "\'");
            return @sText;
        }

推荐答案

@符号允许您为变量名使用保留关键字。例如@class。
The @ symbol allows you to use a reserved keyword for a variable name. Such as @class.


这篇关于在变量命名中使用@作为前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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