I'm currently having problem with creating an abstract class, implementing it, and making a new instance.
Even though I've instantiated it, and set values, its properties still return to null.
This is my abstract class Code:
public abstract class AuthData { private string _VoidCode; private string _SessionID; private DateTime _SessionExp; private int _SessionHours; public abstract string VoidCode { get; set; } public abstract string SessionID { get; set; } public abstract DateTime SessionExp { get; set; } public abstract Int32 SessionHours { get; set; } }
And this is my implementation with Constructor Code:
public class AuthDataConst : AuthData { private string _VoidCode; private string _SessionID; private DateTime _SessionExp; private int _SessionHours; public AuthDataConst(string voidcode, string sessionid, DateTime sessionexp, int sessionhrs) { string _VoidCode = voidcode; string _SessionID = sessionid; DateTime _SessionExp = sessionexp; int _SessionHours = sessionhrs; } public override string VoidCode { get { return this._VoidCode; } set { this._VoidCode = this.VoidCode; } } public override string SessionID { get { return this._SessionID; } set { this._SessionID = this.SessionID; } } public override DateTime SessionExp { get { return this._SessionExp; } set { this._SessionExp = this.SessionExp; } } public override int SessionHours { get { return this._SessionHours; } set { this._SessionHours = this.SessionHours; } } }
Then I tried to make a new instance but its properties still returns null values. Code:
AuthDataConst result = new AuthDataConst("0000", "1234567890", DateTime.Now.AddHours(5), 5);
Even manually setting their values returns same result; all properties are still null. Code:
result.VoidCode = "0000"; result.SessionID = "1234567890"; result.SessionExp = DateTime.Now.AddHours(5); result.SessionHours = 5;


Reply With Quote
