Wrox Programmer Forums
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 26th, 2004, 04:07 AM
Registered User
 
Join Date: Aug 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default arraylists

I have a stored procedure with creates a persons details.
I want to create an array list in visual studio which contains values such as surname [varchar][50] firstname [varchar][50] etc

can anyone help

CodeMonkeys
 
Old August 26th, 2004, 08:06 AM
Authorized User
 
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can use a hashtable and a object to encapsulate your person.

Hashtable persons = new Hashtable(53);

public class Person
    {
        private string Id;
        private string Nombre;

        public string id
        {
            get
            {
                return Id;
            }
        }
....etc, etc

-------------------------------
World only exists into your mind.
 
Old August 27th, 2004, 02:12 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

miguel,I dont think we need hashtables here.
codemonkeys,I dont know how you work with your SP but its better to know
DataRow object has a property called ItemArray,it hold all the fields in your
row as an object array...
its easier to work with this,then you can join this array to your arraylist object like below...
Code:
yourArrayList.AddRange(currentDataRow.ItemArray);
now every item in your arraylist has own type i.e,
varchar(sql)<------>string(.NET)
HtH.

--------------------------------------------
Mehdi.:)
 
Old August 31st, 2004, 04:25 PM
Authorized User
 
Join Date: Jul 2004
Posts: 69
Thanks: 0
Thanked 1 Time in 1 Post
Default

You could also make a class that holds the pertanent information and then add the instances into an arraylist.

www.CoderForRent.com
Get A Computer Job!





Similar Threads
Thread Thread Starter Forum Replies Last Post
ArrayLists - book question Jerry Obrien VB.NET 2002/2003 Basics 0 February 9th, 2004 01:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.