本文介绍了创建新类错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我试图创建一个类,但我继续得到这个错误。



错误1'GatePass.clsDSLApp.clsDSLApp()'必须声明一个正文,因为它没有标记为abstract,extern或partial





这里是下面的代码,请提供帮助。



错误1'GatePass.clsDSLApp.clsDSLApp()'必须声明一个正文,因为它没有标记为abstract,extern或partial C:\ Users \Monde \Documents\Visual Studio 2008 \Projects\GatePass\GatePass \clsDSLApp.cs 9 16 GatePass



Hi All,

Im trying to create a class, but i keep on getting this error.

Error1'GatePass.clsDSLApp.clsDSLApp()' must declare a body because it is not marked abstract, extern, or partial


here is the code below, please assist.

Error1'GatePass.clsDSLApp.clsDSLApp()' must declare a body because it is not marked abstract, extern, or partialC:\Users\Monde\Documents\Visual Studio 2008\Projects\GatePass\GatePass\clsDSLApp.cs916GatePass

namespace GatePass
{
    public class clsDSLApp : clsDSLBase
    {
        public clsDSLApp();

        public bool FillComboBoxDataSet(ref ComboBox cboComboBox, DataSet dsRecords, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxSQL(ref ComboBox cboComboBox, string strSQL, int intConnectionIndex, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxSQL(ref ComboBox cboComboBox, string strSQL, string strConnectionString, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxXML(ref ComboBox cboComboBox, string strXMLFileName, string strSQL, int intConnectionIndex, bool blnRecreateXML, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);





}

}



}
}

推荐答案

namespace GatePass
{
    public class clsDSLApp : clsDSLBase
    {
        public clsDSLApp() {
            // Do STuff
        }       
 
        // Do other methods likewise
    }
}





或创建一个界面而不是一个类:



or create an interface instead of a class:

namespace GatePass
{
    public interface clsDSLApp
    {

         bool FillComboBoxDataSet(ref ComboBox cboComboBox, DataSet dsRecords, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
         bool FillComboBoxSQL(ref ComboBox cboComboBox, string strSQL, int intConnectionIndex, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
         bool FillComboBoxSQL(ref ComboBox cboComboBox, string strSQL, string strConnectionString, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
         bool FillComboBoxXML(ref ComboBox cboComboBox, string strXMLFileName, string strSQL, int intConnectionIndex, bool blnRecreateXML, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex); 
    }
}





您也可以将类声明为抽象,从而强制继承此类的其他类实现它们等。



You could also declare the class as abstract and thus force other classes inheriting this class to implement them etc.


public class clsDSLApp : clsDSLBase
    {
        public clsDSLApp() {}

        public bool FillComboBoxDataSet(ref ComboBox cboComboBox, DataSet dsRecords, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxSQL(ref ComboBox cboComboBox, string strSQL, int intConnectionIndex, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxSQL(ref ComboBox cboComboBox, string strSQL, string strConnectionString, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxXML(ref ComboBox cboComboBox, string strXMLFileName, string strSQL, int intConnectionIndex, bool blnRecreateXML, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
}

或者,要获得完全相同的效果,只需删除该行!

Or, to have exactly the same effect, just delete the line!

public class clsDSLApp : clsDSLBase
    {
        public bool FillComboBoxDataSet(ref ComboBox cboComboBox, DataSet dsRecords, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxSQL(ref ComboBox cboComboBox, string strSQL, int intConnectionIndex, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxSQL(ref ComboBox cboComboBox, string strSQL, string strConnectionString, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxXML(ref ComboBox cboComboBox, string strXMLFileName, string strSQL, int intConnectionIndex, bool blnRecreateXML, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
}

将在幕后为您创建一个空构造函数。

An empty constructor will be created for you behind the scenes.


这篇关于创建新类错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 09:10