473,396 Members | 1,972 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,396 software developers and data experts.

Need Help in Arrays

here is my class
public class AppointmentRowCollection : Appointment
{
public Appointment[] GetRowsCollection(out int rows)
{
int i = 0;
dataset= new AppointmentDS();
dataset= SelectAppointment();
DataRowCollection drcollection = dataset.Appointments.Rows;
rows = drcollection.Count;
foreach (DataRow row in drcollection)
{
AppointmentID = int.Parse(row["AppointmentID"].ToString());
AppointmentDate= Convert.ToDateTime(row["AppointmentDate"]);
TimeFrom= row["TimeFrom"].ToString();
TimeTo= row["TimeTo"].ToString();
return new Appointment();
}
return null;
}
}

AppointmentID,AppAppointmentDate....... is a public property From
Appointment Class
How ca i return Appointment[] array form my foreach loop??
Nov 16 '05 #1
2 1072
I am not going to go into this - but why do you have a collection inheriting
from the object it is a collection of? This is a poor design. Rather, it
should inherit from CollectionBase (if .NET <= v1.1) or (use generics .NET
= 2.0).
Secondly, I would do the following -

Create an ArrayList and for each Appointment, just go ArrayList.add(new
Appointment() );

Then, return the ArrayList.ToArray() result.

Let me know if this works.

Take care.

--
Nathan

Or
"Islam Elkhayat" <Is******@Free-mail-Domains.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl... here is my class
public class AppointmentRowCollection : Appointment
{
public Appointment[] GetRowsCollection(out int rows)
{
int i = 0;
dataset= new AppointmentDS();
dataset= SelectAppointment();
DataRowCollection drcollection = dataset.Appointments.Rows;
rows = drcollection.Count;
foreach (DataRow row in drcollection)
{
AppointmentID = int.Parse(row["AppointmentID"].ToString());
AppointmentDate= Convert.ToDateTime(row["AppointmentDate"]);
TimeFrom= row["TimeFrom"].ToString();
TimeTo= row["TimeTo"].ToString();
return new Appointment();
}
return null;
}
}

AppointmentID,AppAppointmentDate....... is a public property From
Appointment Class
How ca i return Appointment[] array form my foreach loop??

Nov 16 '05 #2
Thanx.. I'm new in C# so may be i miss some logic..
I'm using v1.1 what is CollectionBase??
I'm just try creat Data access Tier, but i don't have enought info about
this. would u help me to find good resource in how to develop my application
in 3 tier instead of but my code in the codebehind of my webform??

"Nathan Neitzke" <ne******@erau.edu> wrote in message
news:ue**************@TK2MSFTNGP09.phx.gbl...
I am not going to go into this - but why do you have a collection
inheriting from the object it is a collection of? This is a poor design.
Rather, it should inherit from CollectionBase (if .NET <= v1.1) or (use
generics .NET
= 2.0).


Secondly, I would do the following -

Create an ArrayList and for each Appointment, just go ArrayList.add(new
Appointment() );

Then, return the ArrayList.ToArray() result.

Let me know if this works.

Take care.

--
Nathan

Or
"Islam Elkhayat" <Is******@Free-mail-Domains.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
here is my class
public class AppointmentRowCollection : Appointment
{
public Appointment[] GetRowsCollection(out int rows)
{
int i = 0;
dataset= new AppointmentDS();
dataset= SelectAppointment();
DataRowCollection drcollection = dataset.Appointments.Rows;
rows = drcollection.Count;
foreach (DataRow row in drcollection)
{
AppointmentID = int.Parse(row["AppointmentID"].ToString());
AppointmentDate= Convert.ToDateTime(row["AppointmentDate"]);
TimeFrom= row["TimeFrom"].ToString();
TimeTo= row["TimeTo"].ToString();
return new Appointment();
}
return null;
}
}

AppointmentID,AppAppointmentDate....... is a public property From
Appointment Class
How ca i return Appointment[] array form my foreach loop??


Nov 16 '05 #3

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

Similar topics

5
by: Golf Nut | last post by:
I am finding that altering and affecting values in elements in multidimensional arrays is a huge pain in the ass. I cannot seem to find a consistent way to assign values to arrays. Foreach would...
41
by: Psykarrd | last post by:
I am trying to declare a string variable as an array of char's. the code looks like this. char name; then when i try to use the variable it dosn't work, however i am not sure you can use it...
2
by: Pasacco | last post by:
dear I want to ask help on this problem. Array a is partitioned into a0 and a1 in main(). Then a1 is partitioned into a2 and a3 in th_partition() function. And I think this problem is something...
1
by: John Smith | last post by:
I have a two dimentional char array. Before filling it using strtok(), I reset its elements to '\0' using two nested for loops. The code works as I hope it would but I wonder whether I really need...
2
by: Thomas Connolly | last post by:
Anyone know if there is a C# equivallent to: enum { LIFFE_SIZE_AUTOMARKETREF = 15 }; typedef char LiffeAutoMarketReference ; Thanks,
8
by: hothead098 | last post by:
ASSIGNMENT (4) USING AND MANIPUPATING ARRAYS (Chapter 10 material) For this assignment you are to: 1) Create and manage arrays a) One of type integers (containing 10 elements). b) One of...
23
by: vinod.bhavnani | last post by:
Hello all, I need desperate help Here is the problem: My problem today is with multidimensional arrays. Lets say i have an array A this is a 4 dimensional static array.
41
by: Rene Nyffenegger | last post by:
Hello everyone. I am not fluent in JavaScript, so I might overlook the obvious. But in all other programming languages that I know and that have associative arrays, or hashes, the elements in...
6
by: junk | last post by:
Senerio: I have a custom user control which contains two control arrays. The user control has a group box in which the two control arrays are dynamically built. The two control arrays are...
0
by: sumalats | last post by:
Hello, I need to use Visual basic to acquire some data through the serial port, store it etc. As I am just getting acquainted with VB6 I need some help. My Controller board (8 bit micro) sends...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.