'Giving data to a type List by a builder
I am doing a personal project about products and markets that sells them (most of the names are in portuguese) It says that I cannot convert a type (String, int) to a type List. How can I send that data using the builder? Below are the three classes that I am currently using market class:
private String _email;
private List<produto> _produtoList = new List<produto>();
public fornecedor()
{
}
public fornecedor(string Nome, string Email, List<produto> ProdutoList)
{
this.Nome = Nome;
this.Email = Email;
this.ProdutoList = ProdutoList;
}
public String Nome
{
get { return _nome; }
set { _nome = value; }
}
public String Email
{
get { return _email; }
set { _email = value; }
}
public List<produto> ProdutoList
{
get { return _produtoList; }
set
{
_produtoList = value;
}
}```
In the main class I am trying to insert at ProdutoList by the builder I have created. But it gives me an error
Main class:
``` static void Main(string[] args)
{
List<fornecedor> fornecedores = new List<fornecedor>();
fornecedor f1 = new fornecedor("Mercado do bairro", "[email protected]",("Agua", 10));
Console.WriteLine(f1);
Console.ReadKey();
}
}```
Class produto:
```private String _nome;
private int _valorProduto;
public produto()
{
}
public produto(string nome, int valorProduto)
{
Nome = nome;
ValorProduto = valorProduto;
}
public String Nome
{
get { return _nome; }
set { _nome = value; }
}
public int ValorProduto
{
get { return _valorProduto; }
set { _valorProduto = value; }
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
