C#的新手,所以這只是我讀了一些tutiroals後猜測它。C#創建一個實例
我有一個類叫做PS3RemoteDevice:
namespace PS3_BluMote
{
public class PS3RemoteDevice
{
而且從我的主要形式按鈕我嘗試這樣做:
PS3RemoteDevice PS3R = new PS3RemoteDevice;
PS3R.Connect();
當然不過,似乎並沒有工作。因爲我是一個noob會有點幫助會很棒!
謝謝!
大衛
PS3RemoteDevice.cs代碼
using System;
using System.Collections.Generic;
using System.Timers;
using HIDLibrary;
namespace PS3_BluMote
{
public class PS3RemoteDevice
{
public event EventHandler<ButtonData> ButtonAction;
public event EventHandler<EventArgs> Connected;
public event EventHandler<EventArgs> Disconnected;
private HidDevice HidRemote;
private Timer TimerFindRemote;
private Timer TimerHibernation;
private int _vendorID = 0x054c;
private int _productID = 0x0306;
private int _batteryLife = 100;
private bool _hibernationEnabled = false;
public PS3RemoteDevice(int VendorID, int ProductID, bool HibernationEnabled)
{
if (HibernationEnabled)
{
TimerHibernation = new Timer();
TimerHibernation.Interval = 60000;
TimerHibernation.Elapsed += new ElapsedEventHandler(TimerHibernation_Elapsed);
}
_vendorID = VendorID;
_productID = ProductID;
_hibernationEnabled = HibernationEnabled;
}
public void Connect()
{
if (!FindRemote())
{
StartRemoteFindTimer();
}
}
等等等等....
你在那裏有一些語法錯誤,那是你在說什麼?而不是我們猜測,你應該告訴我們錯誤。 –
PS3RemoteDevice PS3R = new PS3RemoteDevice();代替? (是一個編譯錯誤)如果不是那麼真的不能幫助你,除非你向我們展示庫代碼或將我們鏈接到你使用的庫 –
你缺少構造函數括號:'new PS3RemoteDevice();' – BrokenGlass