![](/img/trans.png)
[英]Invalid token ';' in class, struct, or interface member declaration
[英]Error: Invalid token '=' in class, struct, or interface member declaration
晚上好,我在vb.net的項目中使用了ac#編寫的庫,除某些命令外,它們都能正常工作,要使其正常工作,我必須下載源庫代碼,並從長整數更改變量的類型,但要多少我嘗試重新編譯它,但出現了以下兩個錯誤:
錯誤1在類,結構或接口C的成員聲明中無效的令牌'=':\\ Users \\ Luca \\ Desktop \\ TLSharp-master \\ TeleSharp.TL \\ TLMethod.cs 23 48 TeleSharp.TL
錯誤2在類,結構或接口C的成員中無效的令牌'=':\\ Users \\ Luca \\ Desktop \\ TLSharp-master \\ TeleSharp.TL \\ TLMethod.cs 24 48 TeleSharp.TL
請參考以下代碼:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TeleSharp.TL;
namespace TeleSharp.TL
{
public abstract class TLMethod : TLObject
{
public abstract void deserializeResponse(BinaryReader stream);
#region MTPROTO
public long MessageId { get; set; }
public int Sequence { get; set; }
public bool Dirty { get; set; }
public bool Sended { get; private set; }
public DateTime SendTime { get; private set; }
public bool ConfirmReceived { get; set; }
public virtual bool Confirmed { get; } = true;
public virtual bool Responded { get; } = false;
public virtual void OnSendSuccess()
{
SendTime = DateTime.Now;
Sended = true;
}
public virtual void OnConfirm()
{
ConfirmReceived = true;
}
public bool NeedResend
{
get
{
return Dirty || (Confirmed && !ConfirmReceived && DateTime.Now - SendTime > TimeSpan.FromSeconds(3));
}
}
#endregion
}
}
我對C#有非常膚淺的了解,如何解決這些錯誤?
更改這些屬性
public virtual bool Confirmed { get; } = true;
public virtual bool Responded { get; } = false;
可能您想這樣做:
public virtual bool Confirmed { get {return true; } }
public virtual bool Responded { get {return false; } }
根據c#的版本,這些屬性將引發錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.