C# 带数组的搜索栏
我正在尝试使用带有数组的搜索栏C# 带数组的搜索栏,c#,xaml,xamarin.forms,C#,Xaml,Xamarin.forms,我正在尝试使用带有数组的搜索栏 void Handle_SearchButtonPressed(object sender, System.EventArgs e) { Repositorio repo = new Repositorio(); Cliente[] listacliente = repo.getCliente(); List<Cliente> lst = listacliente.
void Handle_SearchButtonPressed(object sender, System.EventArgs e)
{
Repositorio repo = new Repositorio();
Cliente[] listacliente = repo.getCliente();
List<Cliente> lst = listacliente.OfType<Cliente>().ToList();
var ClienteSearched = lst.Where(l => l.Contains(SearchBar.Text));
ListaClientes.ItemsSource = ClienteSearched;
}
void Handle\u searchbutton按下(对象发送方,System.EventArgs e)
{
Repositorio repo=新的Repositorio();
Cliente[]listacliente=repo.getCliente();
List lst=listacliente.OfType().ToList();
var clientesearch=lst.Where(l=>l.Contains(SearchBar.Text));
ListaClientes.ItemsSource=clientesearch;
}
但它不起作用,我想知道是否有办法让它起作用
这是一节课
public class Cliente
{
[JsonProperty("Cliente1")]
public string Cliente1 { get; set; }
[PrimaryKey]
public string Correo { get; set; }
public string Telefono { get; set; }
public string Calle { get; set; }
public string Hab { get; set; }
public string Ciudad { get; set; }
public string Estado { get; set; }
public Nullable<int> Zip { get; set; }
public int Row { get; set; }
public string Celular { get; set; }
public string ID { get; set; }
}
```
and this is the error
Error CS1929
公共类客户
{
[JsonProperty(“客户1”)]
公共字符串client1{get;set;}
[主密钥]
公共字符串Correo{get;set;}
公共字符串Telefono{get;set;}
公共字符串调用方{get;set;}
公共字符串Hab{get;set;}
公共字符串Ciudad{get;set;}
公共字符串Estado{get;set;}
公共可为空的Zip{get;set;}
公共int行{get;set;}
公共字符串Celular{get;set;}
公共字符串ID{get;set;}
}
```
这就是错误所在
错误CS1929
Cliente
没有Contains
方法。您需要对客户机的一个字符串属性调用Contains
,如下所示
var ClienteSearched = lst.Where(l => l.Cliente1.Contains(SearchBar.Text));
“不工作”不是对问题的有用描述。您是否收到错误或异常?你有没有通过代码验证每一行都在做它应该做的事情?让Cliente ClassI的定义编辑这个问题,并发布类和错误号thanksok,错误在哪一行是有趣的?