Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / May 2008

Tip: Looking for answers? Try searching our database.

returning values from a class?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andy B - 25 May 2008 01:40 GMT
I need to make a class and not quite sure how to go about doing this part. I
want the class to take user input, build a dataset based on that input and
then return it from the class so it can be used elsewhere. A few things
about the dataset and the class that builds the dataset:

1. The dataset should already have prebuilt tables and columns that need to
be filled in like Header, Sections, Glossary, FormHeader, Contacts and
FormFooter. The other table, EventsForm has to be created "on the fly".
2. The class that generates the dataset needs to have different methods. A
method for each table and one for actually returning the dataset to an
application for use.

Where would I get started doing something like this? I do know how to make
classes in general, but not using "global" objects in a class.
Peter Duniho - 25 May 2008 02:11 GMT
> [...]
> Where would I get started doing something like this? I do know how to  
> make
> classes in general, but not using "global" objects in a class.

Your question is not very clear.  Are you having trouble with the DataSet  
and/or DataTable instantiation?  Or is this more of an architectural  
question, where the fact that you're dealing with those specific classes  
(DataSet and DataTable) isn't specifically relevant?

If the latter, then it sounds as though you're looking for the "static"  
keyword, which allows you to write a method in a class where there's no  
need to have an actual instance of that class.

If that's not the answer, you may want to consider rephrasing your  
question, making sure you leave out everything that is not strictly  
relevant, and making sure that anything that is relevant, you explain  
_why_ it's relevant.

Pete
zane546@hotmail.com - 25 May 2008 12:53 GMT
> I need to make a class and not quite sure how to go about doing this part. I
> want the class to take user input, build a dataset based on that input and
[quoted text clipped - 10 lines]
> Where would I get started doing something like this? I do know how to make
> classes in general, but not using "global" objects in a class.

I'm not sure I understand the question. If you are asking about the
simplest/most common way to have a class accept input and return a
DataSet is to create a method which takes the input as the arguments
and returns the DataSet it builds:

DataSet myOperation(argument1, argument2, ...)

Exposing internal variables and objects of a class is generally not a
good idea, since other classes may change these variables - even to
illegal values - without the class knowing about it, causing problems.
The idea of using methods to access internal variables is to have the
class know which variables are being modified (and restricting those
which cannot), and also to validate any data given as input.

--
LAILA PAAVILAINEN JAN AALTOLA EERO PARTANEN
SANNA KASKILAHTI IIKKA PAAVOLAINEN  LAILA NIEMINEN
TUUKKA ANTTOLAINEN PAAVO PALOLUOMA TAINA HAAPIAINEN

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.