gpt4 book ai didi

c# - 从通用列表中查找符合任何条件的项目

转载 作者:太空宇宙 更新时间:2023-11-03 16:52:35 25 4
gpt4 key购买 nike

我在名为 lst_Patient 的列表中收集了患者。

这是我从用户那里获取信息的方法:

 public  Patient[] GetPatientsBySearchParams(DataPair[] dataPair)
{
//return the array patients that match any of the criteria
//Right Now I ma doing this didn't get any success :

List<Patient> P = new List<Patient>();

P = lst_Patient.FindAll(p => { p.FirstName = dataPair[0].OutputValue.ToString();
p.LastName = dataPair[1].OutputValue.ToString();
return true;
return P.ToArray();

}

在按钮上单击我获取用户在文本框中输入的信息:

 private DataPair[] dpair;
private void Button_Click(object sender, RoutedEventArgs e)
{
InvalidSearch.Visibility = Visibility.Collapsed;
SearchResults.Visibility = Visibility.Visible;

dpair = new DataPair[]{
new DataPair { Name = "FirstName", OutputValue = fst_Name.Text },
new DataPair { Name = "LastName", OutputValue = lst_Name.Text },
new DataPair { Name = "DateOfBirth", OutputValue = dob.Text },
new DataPair { Name = "SSN", OutputValue = ssn.Text },
new DataPair { Name = "PracticeNumber", OutputValue = pract_nbr.Text },
new DataPair { Name = "ReferenceNumber", OutputValue = ref_nbr.Text },
new DataPair { Name = "PlaceOfService", OutputValue = pos.Text },
new DataPair { Name = "DateOfService", OutputValue = dos.Text},
new DataPair { Name = "RenderingProvider", OutputValue = rndrng_prov.Text },
new DataPair { Name = "AdmissionDate", OutputValue = admsn_date.Text }
};

this.FetchData();
}


private void FetchData()
{

Patient[] p = client.GetPatientsBySearchParams(dpair);

}

最佳答案

public  Patient[] GetPatientsBySearchParams(DataPair[] dataPair)
{
P = lst_Patient.FindAll(
delegate(Patient tmp){
if(tmp.FirstName = dataPair[0].OutputValue || tmp.LastName = dataPair[1].OutputValue)
return true;
else
return false;
}
);

return P.ToArray();
}

关于c# - 从通用列表中查找符合任何条件的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3422475/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com