sidepie101
New Coder
I am a newbie on C# and I am trying to make a program to handle orders from customers. I created my object and added a method to read the user input but I am still struggling with creating a list where user can add products by putting in their properties ( name, code and price).
Here is what I got so far :
public class Produit
{
public string? NomProduits { get; set; }
public string? CodeProduits { get; set; }
public string? PrixProduits { get; set; }
}
public class AttributsProduits
{
public static void AjouterProduits ()
{
Produit ReadProduits()
{
return new Produit()
{
NomProduits = Console.ReadLine(),
CodeProduits = Console.ReadLine(),
PrixProduits = Console.ReadLine(),
};
}
}
}
I created the object and its attributes, and added a method to read said attributes from the user. This is what I did for the list but Im getting an error CS1729 :
List<Produit> produits = new List<Produit>();
produits.Add(new Produit(NomProduits));
produits.Add(new Produit(CodeProduits));
produits.Add(new Produit(PrixProduits));
Can anyone help me with this please?
Adding objects to an existing list
Here is what I got so far :
public class Produit
{
public string? NomProduits { get; set; }
public string? CodeProduits { get; set; }
public string? PrixProduits { get; set; }
}
public class AttributsProduits
{
public static void AjouterProduits ()
{
Produit ReadProduits()
{
return new Produit()
{
NomProduits = Console.ReadLine(),
CodeProduits = Console.ReadLine(),
PrixProduits = Console.ReadLine(),
};
}
}
}
I created the object and its attributes, and added a method to read said attributes from the user. This is what I did for the list but Im getting an error CS1729 :
List<Produit> produits = new List<Produit>();
produits.Add(new Produit(NomProduits));
produits.Add(new Produit(CodeProduits));
produits.Add(new Produit(PrixProduits));
Can anyone help me with this please?
Adding objects to an existing list