[英]How to pass reference of model in ASP.net MVC 5 Function?
I have a service with a function public bool UpdateSubClient(ref SubClient subClient)
which updates the database. 我有一个带有函数
public bool UpdateSubClient(ref SubClient subClient)
的服务,该服务更新数据库。
Subclient model is as follow 子客户端模型如下
public string SubClientName { get; set; }
public string BtnText { get; set;}
public string HdrText { get; set; }
public string ReturnURL { get; set; }
I am trying to call the the UpdateSubclient as follows 我正在尝试如下调用UpdateSubclient
SubClientService subclientservice = new SubClientService();
SubClient currentsubclient = new SubClient();
currentsubclient.SubClientName = form["SubClientName"].ToString();
currentsubclient.ClientID = Convert.ToInt32(form["ClientID"]);
currentsubclient.BtnText = form["BtnText"].ToString();
currentsubclient.HdrText = form["HdrText"].ToString();
currentsubclient.ReturnURL = form["ReturnURL"].ToString();
bool success = subclientservice.UpdateSubClient(currentsubclient);
I am getting invalid argument error and couldn't figure out the way to pass reference. 我收到无效的参数错误,无法找出传递引用的方式。 Any help will be appreciated.
任何帮助将不胜感激。
I made a change request to other backend developers and changed the 我向其他后端开发人员提出了更改请求,并更改了
public bool UpdateSubClient(ref SubClient subClient)
to 至
public bool UpdateSubClient(SubClient subClient)
to avoid any complications. 避免任何并发症。 Thanks @user2864740 insisting me to research on usages of ref as parameter.
感谢@ user2864740坚持让我研究ref作为参数的用法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.