0
public partial class CityDetailPage : System.Web.UI.Page
{
 protected List<CityPhotoGallery> cityPhotoGallery;--It is allowed
 protected var cityPhotoGallery; --IT IS NOT ALLOWED

 protected void Page_Load(object sender, EventArgs e)
 {

 }

}

我知道如何将普通变量(其数据类型已知)从 aspx.cs 页面传递到 .aspx 页面,但是在我当前的 senerio 中有一个 var 类型变量,所以我如何将此变量从 .aspx.cs 传递到 .aspx 页面页

4

1 回答 1

0

There is no such thing as a var type.

The datatype is either anonymous, e.g. when you use a projection in linq-2-sql or it is the actual datatype derived by the compiler. In that case using var is just shorter.

update You cannot pass an anonymous type. You just need to use the definite type. If you want to pass around a projection, you need to create a specific type for that. They are called Poco or DTO (data transfer) object. They function as simple data containers and are used for moving data between the layers of an application

For more information POCO vs DTO

于 2012-06-23T08:42:20.683 回答