如何在没有返回任何值的情况下停止控制器 [英] How to Stop a Controller with out returning any value
本文介绍了如何在没有返回任何值的情况下停止控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想停止一个控制器而没有返回任何值,我需要像这样返回
I Want to Stop a Controller with out returning any value for that I need to return like this
public int BackgroundService(string lati, string longi)
{
BackGroundService objBGServices = new BackGroundService();
return objBGServices.DispatcherTimerSetup(httpClient, lati, longi, UserId);
}
但我收到的错误如
错误:
错误83无法将类型'void'隐式转换为'int'
but i am getting error like
Error:
Error 83 Cannot implicitly convert type 'void' to 'int'
推荐答案
如果您可以更改方法签名,请将其设置为返回void
而不是int
。
另一方面,如果你不能更改方法签名然后替换
If you can change the method signature the make it returnvoid
instead ofint
.
On the other hand, if you can't change the method signature then replace
引用:
返回objBGServices.DispatcherTimerSetup(httpClient,lati,longi,UserId);
return objBGServices.DispatcherTimerSetup(httpClient, lati, longi, UserId);
with
with
objBGServices.DispatcherTimerSetup(httpClient, lati, longi, UserId);
return 0; // or whatever int value that makes sense
这篇关于如何在没有返回任何值的情况下停止控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文