简体   繁体   中英

Error: Invalid token '=' in class, struct, or interface member declaration

Good evening, I used ac # written library in my project in vb.net, works perfectly except for some commands, to make them work I had to download the source library code and change the type of a variable from long integer , but how much I tried to recompile it I got these 2 errors:

Error 1 Invalid Token '=' in the member declaration of the class, structure or interface C: \\ Users \\ Luca \\ Desktop \\ TLSharp-master \\ TeleSharp.TL \\ TLMethod.cs 23 48 TeleSharp.TL

Error 2 Invalid Token '=' in the member of the class, structure, or interface C: \\ Users \\ Luca \\ Desktop \\ TLSharp-master \\ TeleSharp.TL \\ TLMethod.cs 24 48 TeleSharp.TL

Refer to this code:

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

    }
}

I have a very superficial knowledge of C#, how could I fix these errors?

Change those properties

public virtual bool Confirmed { get; } = true;
public virtual bool Responded { get; } = false;

probably you want to do this:

public virtual bool Confirmed { get {return true; } }
public virtual bool Responded { get {return false; } }

Depending of the version of c# those properties would raise error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM