ASP.Net @符号 [英] ASP.Net @ Symbol

查看:101
本文介绍了ASP.Net @符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图遵循ASP.Net和我的生活中的一些教程,我只是想不通的 @ 符号做什么时,它是前一个变量。

I am trying to follow some tutorials for ASP.Net and for the life of me, I just can't figure out what the @ Symbol does when it is before an variable.

我认为这只是一个快捷方式到任何会话变量或的Request.Form,但我已经在一些地方尝试过没有任何运气。

I thought it was just a shortcut to either session variables or request.form, but I have tried it in a few places without any luck.

当我把它放在随便什么地方,我得到的错误:防爆pression预期,但是,当我看着我从工作的例子,他们不看像前pressions让我很困惑!

When I put it in somewhere at random, I get the error : Expression Expected, however, when I look at the examples I am working from, they do not look like expressions so I am very confused!

请帮帮忙!?

推荐答案

在C#中的 @ 符号,您可以使用关键字作为变量名。

The @ symbol in C# allows you to use a keyword as a variable name.

例如:

//this will throw an exception, in C# class is a keyword
string class = "CSS class name"; 

//this won't
string @class = "CSS class name";

通常最好避免使用关键字作为变量名,但有时它比有尴尬的变量名更优雅。你会经常看到他们的网络和匿名类型的连载东西的时候。

Usually it's best to avoid using keywords as variable names, but sometimes it's more elegant than having awkward variable names. You tend to most often see them when serialising stuff for the web and in anon types.

您的错误可能是由于应用 @ 前一个变量名不是关键字。

Your error is probably due to applying the @ before a variable name that isn't a keyword.

更新:

在T-SQL @ 参数名前总是使用,例如:

In T-SQL @ is always used before parameter names, for instance:

select * 
from [mytable]
where [mytable].[recId] = @id

您会再指定@id参数,当你调用查询。

You would then specify the @id parameter when you called the query.

这篇关于ASP.Net @符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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