C# 当我做一个地理编码器时,我得到了以下错误文本的崩溃:“quot;System.ArgumentNullException,参数不能为空";
我正在做一个地理编码器,我的字符串(有值)有问题,我得到以下错误: System.ArgumentNullException,参数不能为null 代码如下:C# 当我做一个地理编码器时,我得到了以下错误文本的崩溃:“quot;System.ArgumentNullException,参数不能为空";,c#,xamarin,xamarin.forms,maps,C#,Xamarin,Xamarin.forms,Maps,我正在做一个地理编码器,我的字符串(有值)有问题,我得到以下错误: System.ArgumentNullException,参数不能为null 代码如下: async void loadItem () { var getItems = await parseAPI.getOurMainInfo (Application.Current.Properties ["sessionToken"].ToString ()); foreach (var currentI
async void loadItem ()
{
var getItems = await parseAPI.getOurMainInfo (Application.Current.Properties ["sessionToken"].ToString ());
foreach (var currentItem in getItems["results"]) {
infoString = currentItem ["ourInfoDatabase"].ToString (); //gets stored on the database.
}
var info = infoString; //it says i get the error here.
// my string is not empty/null.
// when I run it in system.diagnostics.debug.writeline it gives me a value and it gets stored on the database.
Geocoder gc = new Geocoder ();
Task<IEnumerable<Position>> result =
gc.GetPositionsForAddressAsync (info);
IEnumerable<Position> data = await result;
foreach (Position p in data) {
}
}
async void loadItem()
{
var getItems=await parseAPI.getourmainfo(Application.Current.Properties[“sessionToken”].ToString());
foreach(getItems[“结果”]中的var currentItem){
infoString=currentItem[“ourinfo数据库”]。ToString();//存储在数据库中。
}
var info=infoString;//它说我在这里得到了错误。
//我的字符串不是空的/空的。
//当我在system.diagnostics.debug.writeline中运行它时,它会给我一个值,并存储在数据库中。
Geocoder gc=新的Geocoder();
任务结果=
gc.GetPositionsForAddressAsync(信息);
IEnumerable data=等待结果;
foreach(数据中的位置p){
}
}
我可以编写一个代码来防止崩溃吗?只需放置调试点,请检查您在
var info=infoString中得到的值//上面说我这里有错误。控制台写入线(“Val信息”+Info)代码>是的,它没有得到值,但是如果我有时得到的值是空的呢?a是否可以编写代码以某种方式防止崩溃?或者使用if=!null(){运行代码?}是的,我上面的代码解决了:)太好了