c#
-
i want too write an array that contain 2000 product info the product has id and discribtion and number of unit the number of unit should be changeable thank u all for your help :)
-
i want too write an array that contain 2000 product info the product has id and discribtion and number of unit the number of unit should be changeable thank u all for your help :)
-
i want too write an array that contain 2000 product info the product has id and discribtion and number of unit the number of unit should be changeable thank u all for your help :)
I suspect you want to define a class to hold info on a product and then use a List (not an array) of that class.
-
i want too write an array that contain 2000 product info the product has id and discribtion and number of unit the number of unit should be changeable thank u all for your help :)
This has a big smell of homework about it, so I won't give you code! Create a class (called
Product
) which has public propertiesId
,Description
andCount
The first two properties may not require apublic
set method, just a get so you should make theseprivate
orprotected
, but the final one will require both as public. You could use a backing field, or allow it to be automatic. It would be a good idea to provide a constructor which takes three parameters and sets the appropriate properties. You can then create an array of the class which has sufficient elements or (preferably) a List which meaans that you do not have to worry about the number of elements at any point. To declare an array of any class:MyClass[] myArrayOfClass = new MyClass[2000];
To declare it as a List:
List<MyClass> myListOfClass = new List<MyClass>();
Neither of these allocate any actual instances of the class itself - just the structures that will store them. In both cases, you will have to allocate each instance with the
new
keyword, and add it into the appropriate structure.Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
This has a big smell of homework about it, so I won't give you code! Create a class (called
Product
) which has public propertiesId
,Description
andCount
The first two properties may not require apublic
set method, just a get so you should make theseprivate
orprotected
, but the final one will require both as public. You could use a backing field, or allow it to be automatic. It would be a good idea to provide a constructor which takes three parameters and sets the appropriate properties. You can then create an array of the class which has sufficient elements or (preferably) a List which meaans that you do not have to worry about the number of elements at any point. To declare an array of any class:MyClass[] myArrayOfClass = new MyClass[2000];
To declare it as a List:
List<MyClass> myListOfClass = new List<MyClass>();
Neither of these allocate any actual instances of the class itself - just the structures that will store them. In both cases, you will have to allocate each instance with the
new
keyword, and add it into the appropriate structure.Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
OriginalGriff wrote:
This has a big smell of homework about it, so I won't give you code!
Would you give code if it was not homework? Why would homework be different than work? As long as they tried and searched themselves I find a homework question as valid as a work question. :confused:
V.
-
OriginalGriff wrote:
This has a big smell of homework about it, so I won't give you code!
Would you give code if it was not homework? Why would homework be different than work? As long as they tried and searched themselves I find a homework question as valid as a work question. :confused:
V.
Yes - and I do. I will even give code if it is homework and they have made a show of trying to do it and failed. But when it is clearly homework and they haven't done anything at all, no - I will give a fair amount of help (as I think I did here) but the only way they will learn it properly is to do it themselves. Just giving them the code doesn't help them to learn, and gives the teacher the wrong idea about how well his students are picking up the course. Otherwise, they could just get us to do all the homework, qualify by learning nothing, and then get a job working beside you, or me. I don't want that, and I don't think many people do.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
OriginalGriff wrote:
This has a big smell of homework about it, so I won't give you code!
Would you give code if it was not homework? Why would homework be different than work? As long as they tried and searched themselves I find a homework question as valid as a work question. :confused:
V.
V. wrote:
I find a homework question as valid as a work question
I don't, but that doesn't matter here, this question is concerned with very basic concepts that even a hobbyist should already know.
-
Yes - and I do. I will even give code if it is homework and they have made a show of trying to do it and failed. But when it is clearly homework and they haven't done anything at all, no - I will give a fair amount of help (as I think I did here) but the only way they will learn it properly is to do it themselves. Just giving them the code doesn't help them to learn, and gives the teacher the wrong idea about how well his students are picking up the course. Otherwise, they could just get us to do all the homework, qualify by learning nothing, and then get a job working beside you, or me. I don't want that, and I don't think many people do.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
i want too write an array that contain 2000 product info the product has id and discribtion and number of unit the number of unit should be changeable thank u all for your help :)
-
i want too write an array that contain 2000 product info the product has id and discribtion and number of unit the number of unit should be changeable thank u all for your help :)