积极答复者
winrt组件改写,原来函数带ref

问题
答案
-
我是这样写的,在异步(async)方法中不能使用ref out,不是异步的可以
方法定义:
private void SearchLocation(string City, ref Location location)
{
foreach (Data.BingMap item in (this.DataContext as Data.ViewModelBingMap).BingMapView)
{
if (item.DescCity.Equals(City.Trim()))
{
location.Latitude = item.Latitude;
location.Longitude = item.Longitude;
break;
}}
}引用:
Bing.Maps.Location location = new Bing.Maps.Location();
SearchLocation((sender as Pushpin).Text, ref location);不知道是否对你有用。
maming
- 已标记为答案 Aaron XueModerator 2012年12月4日 10:53
全部回复
-
我是这样写的,在异步(async)方法中不能使用ref out,不是异步的可以
方法定义:
private void SearchLocation(string City, ref Location location)
{
foreach (Data.BingMap item in (this.DataContext as Data.ViewModelBingMap).BingMapView)
{
if (item.DescCity.Equals(City.Trim()))
{
location.Latitude = item.Latitude;
location.Longitude = item.Longitude;
break;
}}
}引用:
Bing.Maps.Location location = new Bing.Maps.Location();
SearchLocation((sender as Pushpin).Text, ref location);不知道是否对你有用。
maming
- 已标记为答案 Aaron XueModerator 2012年12月4日 10:53
-
Hi,
这个在组件中的确是没办法用的,我建议参数直接使用引用类型比较好。
Aaron Xue [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.