0
我怎樣才能在c#wpf中創建一個接口的實例,主要問題是它已被聲明在名爲「GLOBAL」的靜態類中;c#wpf接口實例創建
接口名稱是「IcuttingMac」
public static class Global {
public static DataTable ProgramNamesTable = null;
//public const string BuildNo = "Build No. 1.0.0 dt. 2014/06/11";
//public const string CopyRight = "(c) Proteck Machinery Pvt. Ltd.,\nChennai, INDIA";
public static Cutting_Machine.CutMACStatus cutmacstatus;
public static ICuttingmac Icutmacobj;
// public static ICuttingMac Icuttingobj = new ICuttingMac();
////UNCOMMENT THIS for PROTECH PLC
public const string DATAPATH = "\\Hard Disk\\cmp";
這個S在另一個文件中創建的接口請幫我解決;
這是拋出一個異常,即要創建的新實例;
public interface ICuttingmac : IDisposable {
#region Settings
CMModel cmmodel { get; set; }
ProgStartup progstartup { get; set; }
float Homeposition { get; set; }
float Stackposition { get; set; }
float Rearlimit { get; set; }
float Frontlimit { get; set; }
float FrontlimitwFC { get; set; }
int PositionMUL { get; set; }
int PositionDIV { get; set; }
float Slowjogspeed { get; set; }
float Fastjogspeed { get; set; }
float Inchingdist { get; set; }
short Maxcutsperknife { get; set; }
float Homespeed { get; set; }
float HomeAccl { get; set; }
ushort Knifespeed { get; set; }
ushort Knifechangespeed { get; set; }
ushort Kniferapidspeed { get; set; }
ushort Knifeslowspeed { get; set; }
ushort KnifeDECspeed1 { get; set; }
ushort KnifeDECspeed2 { get; set; }
ushort Kniferamp { get; set; }
ushort Clampmult { get; set; }
ushort ClampDiv { get; set; }
ushort ActKnifeAO { get; }
ushort ActClmpAO { get; }
void Setknifespeed(int ix, ushort speed);
//void LoadCmsettings() { }
//void SaveCmsettings() { }
ushort Getknifespeed(int ix);
#endregion
不能創建一個接口的實例。您需要創建一個實現該接口的類的實例。 –
這是一個靜態類la我如何創建一個實例 – user3733442
不是聲明它的類,而是一個[實現](http://msdn.microsoft.com/zh-cn/library/ms173156.aspx)它。請參閱下面的答案並仔細閱讀。 –