473,378 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

returning values from a class?

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.

Jun 27 '08 #1
2 1342
On Sat, 24 May 2008 17:40:22 -0700, Andy B <a_*****@sbcglobal.netwrote:
[...]
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
Jun 27 '08 #2
On May 25, 3:40*am, "Andy B" <a_bo...@sbcglobal.netwrote:
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.
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
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: nielson | last post by:
I have a class which contains (1) a class variable and (2) a method (e.g., methodA) which returns a reference to the class variable. If the variable has been assigned a value by a constant...
6
by: Krackers | last post by:
How do you write a function which returns a reference to an array. I can only get a function to return a copy of the array itself. I've had a look at some other threads in this group an the return...
18
by: cppaddict | last post by:
Hi, Is it considered bad form to have the subscript operator return a const reference variable? If not, what is the proper way to do it? My question was prompted by the code below, my...
4
by: Siemel Naran | last post by:
Hi. I have found one advantage of returning values through the argument list. It's that we have to store the return value. But when we return by value, we may forgot to store the return value. ...
2
by: Asim Qazi | last post by:
Hi All public class MyResponse { public bool m_bStatus; public string m_szErrorCode; public string m_szMessage; }
4
by: scparker | last post by:
Hello, We have a stored procedure that does a basic insert of values. I am then able to retrieve the ID number created for this new record. We are currently using ASP.NET 2.0 and use N-Tier...
6
by: rowe_newsgroups | last post by:
I just noticed this about value types and return values, and it kind of bugs me that the compiler won't treat it as an error, even with Option Strict On. Try this out: Option Strict On ...
0
by: anuptosh | last post by:
Hi, I have been trying to run the below example to get a Oracle Array as an output from a Java code. This is an example I have found on the web. But, the expected result is that the code should...
2
by: ndeeley | last post by:
Hello, I've written a script which returns the admin rights of users in a table - their access level, and their priviledges. The priviledge are returned to a check box and the admin rights to a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.