我有班级横幅
public class Banner
{
public virtual int Id { get; protected set; }
public virtual string Url { get; set; }
public virtual string Path { get; set; }
public virtual bool Disabled { get; set; }
public virtual string TextField { get; set; }
public virtual DateTime UploadDate { get; set; }
}
在我的代码中的某处,我有一种方法来更改“禁用”的值。
public void ToggleEnableDisable(int Id)
{
Banner banner = _session.Query<Banner>().FirstOrDefault(x => x.Id == Id);
if (banner != null && banner.Disabled)
{
banner = banner.Disabled = false //This isn't working, i get cannot convert source type to target type
}
}
我究竟做错了什么 ?
问题不是您正在设置属性的事实,而是您正在尝试将设置属性的结果用作设置banner
自身的输入。您只想要:
banner.Disabled = false;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句