Pass variable to array?

I want to replace 4 with variable A = 4 type string.

My code as below.

Enumerable.Range(0,dt_configRate.RowCount).Select(Function(s) dt_configRate.Rows(s)(4).ToString).ToArray()

Please guide me about it.

1 Like


Did you try to replace 4 with variable here ? If yes then may I know what error are you getting ?

1 Like

Hi @fairymemay

As @lakshman Suggestion, If you face any error, share the screenshot and explain your query little bit

Try this expression

Enumerable.Range(0,dt_configRate.RowCount).Select(Function(s) dt_configRate.Rows(s)(Convert.ToInt64(ColumnNameorIndex)).ToString).ToArray()


1 Like

Hi @fairymemay ,

If you want to rely on the column name instead of the index, you can use this snippet of code for that:



Entire code →

Enumerable.Range(0,dt_configRate.RowCount).Select(Function(s) dt_configRate.Rows(s)(dt_configRate.Columns("Sheet").Ordinal).ToString).ToArray()

Kind Regards,
Ashwin A.K

1 Like

Mention like this if the variable name is Strinput

Enumerable.Range(0,dt_configRate.RowCount).Select(Function(s) dt_configRate.Rows(s)(Convert.ToInt32(Strinput.ToString)).ToString).ToArray()

Cheers @fairymemay

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.