473,398 Members | 2,120 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,398 software developers and data experts.

C# Array question

Hi,

In my C# windows form MyForm, I would like to have an array which is
[string, SqlParameter]
How do I declare this kind of array in C#?
Thanks for help.
Jason
Dec 28 '06 #1
5 1731
Jason Huang wrote:
In my C# windows form MyForm, I would like to have an array which is
[string, SqlParameter]
How do I declare this kind of array in C#?
If I have understood your question correctly, then you want
an array of either struct or class with those two members.

Arne
Dec 28 '06 #2
Hi Jason,

It's probably not a two-dimensional array that you need but an IDictionary
implementation instead. Anyway, object[,] can be used to declare a two
dimensional jagged array, however, you'll probably want a type-safe solution
regardless. You could use a generic Dictionary in the 2.0 framework
instead, or better yet, create a custom KeyedCollection implementation if
the "string" is actually supposed to represent the name of the SqlParameter
to which it's associated:

class KeyedSqlParameterCollection
: KeyedCollection<string, SqlParameter>
{
public KeyedSqlParameterCollection() { }

protected override string GetKeyForItem(SqlParameter parameter)
{
return parameter.ParameterName;
}
}

KeyedSqlParameterCollection parameters =
new KeyedSqlParameterCollection();

parameters.Add(new SqlParameter("name", "value"));

SqlParameter sqlParam = parameters["name"];

Debug.Assert((string) sqlParam.Value == "value", "Uh oh!");

--
Dave Sexton
http://davesexton.com/blog

"Jason Huang" <Ja************@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi,

In my C# windows form MyForm, I would like to have an array which is
[string, SqlParameter]
How do I declare this kind of array in C#?
Thanks for help.
Jason


Dec 28 '06 #3
Maybe a HashTable?
A HashTable represents a collection of key/value pairs.

Cheers
Fabrizio

"Jason Huang" <Ja************@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi,

In my C# windows form MyForm, I would like to have an array which is
[string, SqlParameter]
How do I declare this kind of array in C#?
Thanks for help.
Jason


Dec 28 '06 #4
How about List<String, SqlParameter .. ?
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Jason Huang" wrote:
Hi,

In my C# windows form MyForm, I would like to have an array which is
[string, SqlParameter]
How do I declare this kind of array in C#?
Thanks for help.
Jason
Dec 28 '06 #5
Hi Peter,

I think you mean Dictionary<string, SqlParameter>? :)

--
Dave Sexton
http://davesexton.com/blog

"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:0D**********************************@microsof t.com...
How about List<String, SqlParameter .. ?
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Jason Huang" wrote:
>Hi,

In my C# windows form MyForm, I would like to have an array which is
[string, SqlParameter]
How do I declare this kind of array in C#?
Thanks for help.
Jason

Dec 28 '06 #6

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

Similar topics

1
by: jonnytansey2 | last post by:
Can anyone out there give me a pointer regarding creating a dynamically-generated drop-down list connected to an array? And is that question as clear as chocolate spread? Here's what I've got....
5
by: Andrew Dixon - Depictions.net | last post by:
Hi Everyone. Bit new to Java and I have question about arrays. I have wrote some code to look for certain substrings within a larger string which work fine. I would like to store each substring...
2
by: Nikhil Patel | last post by:
I have a Jagged array that stores RoutingIDs and theirs corresponding Bank Names. I can access it as myArray. The column index indicates whether the value is RoutingID or a BankName. myArray -...
14
by: WStoreyII | last post by:
quick question i know that a two dimension array is like a chart basically (x columns, y rows) my question is though what would an array with more than two dimensions look like? would it...
2
by: Len via DotNetMonster.com | last post by:
I have to set up a 2d array(13, 4) containing a deck of playing cards. What I am wondering is how to correctly set up the array in the first place, and then how do you access the information once...
2
by: purna chandra | last post by:
Hello, I have a simple question.Hoping not to take much of your valuable time...:-). I am trying to get the data from a string, and am wondering if I get...
21
by: yeti349 | last post by:
Hi, I'm using the following code to retrieve data from an xml file and populate a javascript array. The data is then displayed in html table form. I would like to then be able to sort by each...
4
by: Armand | last post by:
Hi Guys, I have a set of array that I would like to clear and empty out. Since I am using "Array" not "ArrayList", I have been struggling in finding the solution which is a simple prob for those...
5
by: Tom Cole | last post by:
Let's say I have the following JSON string returned from a server-side process: { values: } I then create a JSON object from it using eval() (tell me if this is not what should be done). ...
14
by: =?Utf-8?B?RWR3YXJk?= | last post by:
Hi everybody, To me the following code shouldn't work but it does ! Imports system.String Dim x As String="This,is,a,test" Dim y(1) As String y=x.Split(",") TextBox1.text=y(3) why "Y" which is...
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?
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.