|
-
October 30th, 2008, 04:19 PM
#1
Requesting Stock numbers
I want to write a program that asks for a stocknumber and when it gets my stock number it will bring up the name of the product, can I do this in a console application, any tips folks. I was planning on creating a separate class.
-
October 31st, 2008, 02:18 AM
#2
Re: Requesting Stock numbers
Yes, you could write this in a console. And you could probably have several separate classes.
Were do you want to get the data? Some hard-coded structure? Some file on disk?
-
October 31st, 2008, 08:34 AM
#3
Re: Requesting Stock numbers
can I not call the data from a class, I was comptiplating taking it from a file on my computer but I want to try taking it from a class.
-
October 31st, 2008, 08:40 AM
#4
Re: Requesting Stock numbers
Hi,
there is just a simple way:
- Create a new class which loads the data from any file
and stores into some internal public members, like strings, ints and so one
- Create an instance of this class in your main and call your class' method to
load the data and access the data immediately through this class. This works
if the class members are public.
Few would suggest do have get/set stuff, but I don't like them much ;-)
-
October 31st, 2008, 08:44 AM
#5
Re: Requesting Stock numbers
 Originally Posted by MNovy
Hi,
there is just a simple way:
- Create a new class which loads the data from any file
and stores into some internal public members, like strings, ints and so one
- Create an instance of this class in your main and call your class' method to
load the data and access the data immediately through this class. This works
if the class members are public.
Few would suggest do have get/set stuff, but I don't like them much ;-)
any examples on loading the data from any file
-
October 31st, 2008, 09:04 AM
#6
Re: Requesting Stock numbers
 Originally Posted by johnboy14
any examples on loading the data from any file
Take a look at the FileStream and StreamReader classes
It's not a bug, it's a feature!
-
October 31st, 2008, 09:41 AM
#7
Re: Requesting Stock numbers
can you read from any file type, word, excel or notepad. Would it be easier to write all the current information in one class for the others to read from. I don't quite understand those classes above.
What I want is to give the stocknumber and then get the name of the product off the list, I can only think of identifying them through a class at the moment.
Last edited by johnboy14; October 31st, 2008 at 10:03 AM.
-
October 31st, 2008, 10:20 AM
#8
Re: Requesting Stock numbers
 Originally Posted by MNovy
Few would suggest do have get/set stuff, but I don't like them much ;-)
Exposing (data) Fields directly is a bad practice. If places hard limits on the ability to implement techniques such as agressive/lazy evaluation. Additionally if you later have to change a field to a property, you run the risk of breaking existing code.
Unless you have (the very very rare condition) of having measured a property to introduce overhead that violdates a documented performance specification, there is NO reason to ever have data as anything other than private.
Also remember that with the latest versions of C#, you can use properties with anonymous backing fields, so there is even less reason.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
October 31st, 2008, 10:28 AM
#9
Re: Requesting Stock numbers
What about the DataSet Feature in visual c#.
-
November 3rd, 2008, 01:49 PM
#10
Re: Requesting Stock numbers
 Originally Posted by johnboy14
What about the DataSet Feature in visual c#.
This is my suggestion as well.
The DataTable Class allows you to crate a table that could represent you data and has a functions for saving it as an XML file and populating it from a previously saved XML table. It even has functions to search the table.
This seems like it is exactly what you are looking for.
-
November 3rd, 2008, 02:18 PM
#11
Re: Requesting Stock numbers
 Originally Posted by ifdef
This is my suggestion as well.
The DataTable Class allows you to crate a table that could represent you data and has a functions for saving it as an XML file and populating it from a previously saved XML table. It even has functions to search the table.
This seems like it is exactly what you are looking for.
A DAtaSEt would certainly be a "quick and easy" solution, but it may be "heavy" (especially is DataTable.Select("...") is used!!!!!).
An alternative would be LINQ to XML....
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|