CSharp: How to fix following C# error in Visual Studio: Cannot apply indexing with [] to an expression of type 'System.Data.DataTable'

Error:
Cannot apply indexing with [] to an expression of type 'System.Data.DataTable'

Cause:
string variable = Table[0][1].ToString();

Solution:
DataTable Table;string variable = Table.Rows[index][column-index].ToString();

Example:

DataTable Table;
string variable = Table.Rows[0][1].ToString();

The above error happens when you try to index the datatable without first accessing the "Rows" property. You must first access the "Rows" property and then provide the index.

Hiç yorum yok:

BlackListIP control on Serenity platform (.NET Core)

 In the Serenity platform, if you want to block IPs that belong to people you do not want to come from outside in the .net core web project,...