You can't. Each object is different and the base class is just a template that your other classes extend. Every new
object will create and maintain their own CompanyId
variable, so you can't and shouldn't change the one by changing the other.
Check the static
keyword if you want one value only for all the classes public static Int64 CompanyId { get; set; }
Basically this:
public class CompanyController : BaseController
{
public IActionResult ChangeCompany(long CompanyId = 35) //
{
base.CompanyId = CompanyId;
// other code
}
public IActionResult GetCompany() //
{
return base.CompanyId // return 35
}
}
Is the same as this (though without inheritance, you can't even know which parts the two classes have in common):
public class CompanyController
{
public Int64 CompanyId { get; set; } // I need to update this property
public IActionResult ChangeCompany(long CompanyId = 35) //
{
base.CompanyId = CompanyId;
// other code
}
public IActionResult GetCompany() //
{
return base.CompanyId // return 35
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…