在C#变量名前面放置一个@?(What does placing a @ in front of a C# variable name do? [duplicate])

编程入门 行业动态 更新时间:2024-10-23 16:16:37
在C#变量名前面放置一个@?(What does placing a @ in front of a C# variable name do? [duplicate])

这个问题已经在这里有一个答案:

C#中变量名称中的@字符的用途/含义是什么? 9个答案

我一直在使用一些C#的遗留代码,我在变量名前面看到很多@符号。 这意味着什么?

目前,我在变量前面看到很多没有保留的通用名称。 例如:

MyProcedure(@step.LoadInstanceId, @step.ResultCode, @step.StatusCode);

鉴于这一步不是一个保留词,有没有理由应该逃避?

This question already has an answer here:

What's the use/meaning of the @ character in variable names in C#? 9 answers

I've been working with some C# legacy code and I've been seeing a lot of @ symbols in front of variable names. What does this signify or do?

Currently I'm seeing it a lot in front of variables with common names that aren't reserved. E.g.:

MyProcedure(@step.LoadInstanceId, @step.ResultCode, @step.StatusCode);

Given that step isn't a reserved word, is there any reason that they should be escaped?

最满意答案

这只是一种允许将保留关键字声明为var的方法。

void Foo(int @string)

It's just a way to allow declaring reserved keywords as vars.

void Foo(int @string)

更多推荐

本文发布于:2023-07-17 07:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1141159.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量名   placing   front   variable   duplicate

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!