Answer the question
In order to leave comments, you need to log in
How to add new values to a property?
Let's say I have a project "online grocery store", and in this project there is a class with the store itself. Logically, this store stores products. And for this, a separate class "Product" is implemented. How can I implement the "Product" class in such a way that it would store the product code, the product name, and the price of the product, and then display all this information?
class Magazine
{
public string Product { get; set; }
}
class Product
{
}
Answer the question
In order to leave comments, you need to log in
Hey!
For the property you specified, this is:
Magazine item = new Magazine();
item.Product = "Hook";
class Magazine
{
public string Product { get; init; }
}
Magazine item = new Magazine(){ Product = "Soda" };
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question