Use of @ in a variable name
-
The @ symbol is usually used for SQL Server parameters
SqlCommand.Parameters["@ID"].Value = 1234; CREATE PROC sp_MyProc @ID INT AS SELECT * FROM Table WHERE ID = @ID
The at symbol is also used to escape string literalsstring path = @"C:\Program Files\Some Folder";
only two letters away from being an asset
-
sa_runner wrote:
Is there any significance to the use of the @ in a variable name (like @intx)?
Using @ means that you can have a variable name that (sort of) matches a type name, e.g. object @object. In your code you can then refer to @object. It really doesn't seem to be good practice to me.
Deja View - the feeling that you've seen this post before.
-
In SQL yes, in C# no. You can use it in c# as well, but the only thing that happens is that Intellisense does not work on this variable :-)
-^-^-^-^-^- no risk no funk ................... please vote ------>
-
@ is used to specify an identifier. It's mostly used to access members of third party classes that happen to be keywords in C#. Example:
SomeComponent.@int x = new SomeComponent.@int();
--- single minded; short sighted; long gone;
Interesting, learn something all the time. Can't say as I've every seen this in use, and can't think of a reason why.
only two letters away from being an asset
-
Interesting, learn something all the time. Can't say as I've every seen this in use, and can't think of a reason why.
only two letters away from being an asset
reserved words are different in different languages. It's needed to allow assemblies written in Foo.net to always work in Bar.net without requiring any changes to the Foo.net source code because the author used a variable name that's reserved in Bar.net. MS tries to avoid any situation like this for the languages they officially provide (I've never actually seen it used myself), but the more languages supported the harder it becomes, and 3rd parties don't always have the same degree of foresight into cross language issues. This is an officially sanctioned work around.
-- If you view money as inherently evil, I view it as my duty to assist in making you more virtuous.
-
reserved words are different in different languages. It's needed to allow assemblies written in Foo.net to always work in Bar.net without requiring any changes to the Foo.net source code because the author used a variable name that's reserved in Bar.net. MS tries to avoid any situation like this for the languages they officially provide (I've never actually seen it used myself), but the more languages supported the harder it becomes, and 3rd parties don't always have the same degree of foresight into cross language issues. This is an officially sanctioned work around.
-- If you view money as inherently evil, I view it as my duty to assist in making you more virtuous.
That explains it, thanks.
only two letters away from being an asset
-
That explains it, thanks.
only two letters away from being an asset