因为它没有标记抽象或必须的extern声明主体? C#/ ASP.NET [英] must declare a body because it is not marked abstract or extern? C#/ASP.NET
问题描述
我有code进行正常的Web窗体后面,在这个code后面我可以实例化几个类我在根文件夹,如:
公共部分类_Default:System.Web.UI.Page{
助手帮手=新助手();保护无效的Page_Load(对象发件人,EventArgs的发送)
{
如果(!Page.IsPostBack)
{
初始化();
}
}
而在辅助类:
公共类助手
{
它工作正常,但现在我想将我的类文件(Helper.cs为例)的APP_ code文件夹,但是当我运行该应用程序我得到
错误 的SharePoint的SharePoint =新的SharePoint();公共字符串ID {搞定;组; }必须声明主体,因为它未标记为abstract或EXTERN
是什么原因造成这个问题,如何解决?
在此先感谢
公共字符串ID {搞定;组; }
是一个自动财产,这些在C#3.0 / .NET v3.5版本增加了,所以确保您在打靶项目设置此版本或更高版本。如果你要定位的早期版本,您需要一个支持字段使用属性。
I have a normal web form with code behind, in this code behind I can instantiate a couple of classes I have in the root folder, such as:
public partial class _Default : System.Web.UI.Page
{
Helper helper = new Helper();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Initialise();
}
}
And in the Helper class:
public class Helper
{
It's working fine but I now want to move my class files (Helper.cs for example) to the app_code folder but when I run the application I get error on
SharePoint sharePoint = new SharePoint();
public string id { get; set; }
must declare a body because it is not marked abstract or extern
What is causing this issue and how do I fix it?
Thanks in advance
public string id { get; set; }
is an automatic property and these were added in C# v3.0 / .Net v3.5, so ensure you are targetting this version or higher in your project settings. If you wish to target an earlier version you'll need to use properties with a backing field.
这篇关于因为它没有标记抽象或必须的extern声明主体? C#/ ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!