arrays

G

Guest

I have a two dimensional array. The first dimension is a
number, and the second dimension is a string. Given the
second dimension's value (String), how do I search for the
first dimension?
Thanks for all your inputs.
 
J

Jon Skeet [C# MVP]

I have a two dimensional array. The first dimension is a
number, and the second dimension is a string. Given the
second dimension's value (String), how do I search for the
first dimension?

Dimensions of arrays are never strings - could you give an example of
exactly what you mean?
 
G

Guest

thanks for the reply Jon. only after typing the question I
I realized that my question was wrong. I have a datatable
with several rows. The first column in the datatable has
integer values. The second column has String values. The
values in each row is unique.
Given the value of the second string column, how do we
retrieve the value from the first column. thanks a lot for
your help.
 
N

Nick

DataTable table = new DataTable();
// fill in table here

DataRow[] rows = table.Select("column2 = '" + "myval" + "'");
 
S

Sankar Nemani

There are several ways to acomplish this
drarray = dt.Select("SecondColumnName='the_string_u_r_looking_for'") gives u
an array of rows
if you know for sure the string values are unique, you should get only one
item inthe array
then u can do drarray(0)("firstColumnName") which will give u the integer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top