I have a problem when writing my app, I want to create an Data source that gives me the information of the titles, but it gives me this error;
"The best overloaded method match for 'Systems.Collections.ObjectModel.ObservableCollection.ObservableCollection(System.Collections.Generic.IEnumerable)' has some invalid arguments.
Here is my code;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace App1
{
class DataSourceTitulos
{
public ObservableCollection<Titulos> ListaTitulos { get; set; }
public DataSourceTitulos()
{
Initialize();
}
private int TraerInfoDesdeDatos;
public void Initialize()
{
var listaFull = TraerInfoDesdeDatos;
ListaTitulos = new ObservableCollection<Titulos>(listaFull);
}
}
}
I'd appreciate your help.
new ObservableCollection<Titulos>(listFull)
调用中删除listFull
参数。
ObservableCollection
没有采用int
的构造函数,这就是您要传递的内容。它只有没有参数, List
或IEnumerable
项的构造函数。
Unless I'm missing something, TraerInfoDesdeDatos is never given a value before being used. As well, ObservableCollection has only 3 constructors, one of which is empty and the other two take either an IEnumerable or List. None of them take an int. If you are trying to set the size of the collection, it does not appear that there is a method to do this, but the size is dynamic so you can just add your elements individually anyway.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.