如何在 Xamarin 表单中一一读取 IEnumerable List 值?
How to read IEnumerable List values one by one in Xamarin forms?
我需要读取一个List,它有两个属性,一个是ID int,另一个是string。
在我将值放入列表后,我不知道如何将它们一一分解为 ID 和名称字符串。
这是我得到的:
private async void UpdatePisterosLocal(List<Pisteros> PisterosLista)
{
try
{
PisterosDBController pistDB = new PisterosDBController();
Pisteros_Local pistLocal = new Pisteros_Local();
//this is my code trying to read the list PisterosLista
foreach (string element in PisterosLista)
{
pistLocal.IDPistero = //don't know what to write here
pistLocal.PisteroN = //and here
}
}
catch (Exception ex)
{
throw ex;
}
}
这就是我最终做到的方式
foreach (var item in PisterosLista)
{
var DatosRegistro = new T_Pisteros
{
PisteroID = item.PisteroID,
PisteroN = item.PisteroN
};
var num = db.Insert(DatosRegistro); //insert into new DB
}
我需要读取一个List,它有两个属性,一个是ID int,另一个是string。 在我将值放入列表后,我不知道如何将它们一一分解为 ID 和名称字符串。
这是我得到的:
private async void UpdatePisterosLocal(List<Pisteros> PisterosLista)
{
try
{
PisterosDBController pistDB = new PisterosDBController();
Pisteros_Local pistLocal = new Pisteros_Local();
//this is my code trying to read the list PisterosLista
foreach (string element in PisterosLista)
{
pistLocal.IDPistero = //don't know what to write here
pistLocal.PisteroN = //and here
}
}
catch (Exception ex)
{
throw ex;
}
}
这就是我最终做到的方式
foreach (var item in PisterosLista)
{
var DatosRegistro = new T_Pisteros
{
PisteroID = item.PisteroID,
PisteroN = item.PisteroN
};
var num = db.Insert(DatosRegistro); //insert into new DB
}