How to give datarow type from string

'cannot implicitly convert a type string to a data string []'.

Is it possible to save the row type in the data row []? I need to store the value of a particular column in this particular array of data rows. Offer me an answer.

DataRow[] drprocess = objds.Tables[0].Rows[i]["ProcessName"].ToString(); 
+3
source share
2 answers

You have specified a type variable DataRow[]called drProcess, but have not yet created an array of DataRows into which you want to place any values. Instead, you tried to tell the compiler that the string you are retrieving is actually a DataRow, but it is not.

, DataRows, DataRow . , , , . , objds.Tables[0].Rows DataRows. , .

, , var processes = new List<string>(), process.Add(objds.Tables[0].Rows[i]["ProcessName"].ToString()).

, .

+1

-, a DataRow a DataTable. DataRow? objds.Tables[0].

, , DataRow[], .

, :

DataRow[] drprocess = objds.Tables[0].Rows[i].Field<string>("ProcessName").Split(',')
    .Select(name => {
        DataRow row = objds.Tables[0].NewRow();
        row.SetField("ProcessName", name);
        return row;
    })
    .ToArray();
0

All Articles