How can I convert IList objects to string array?
While working on the telegram bot, some difficulties arose. I get a IList<object>
from google table with some information. I need to convert this IList<object>
to an array of strings. How can I do this?
static void ReadBudgetTypes()
{
var range = $"{settingsSheet}!B3:B";
var request = service.Spreadsheets.Values.Get(SpreadsheetId, range);
var response = request.Execute();
var values = response.Values; // here i get list of objects from google table
if (values != null && values.Count > 0)
{
foreach (var row in values)
{
Console.WriteLine("{0}", row[0]);
}
}
else
{
Console.WriteLine("No data!");
}
}
3
Answers
you can try this:
Try something like this:
Assuming cells may not be strings and may (or may not) have
null
values, you can print for each cell of the row:or the whole row, joined by a separator
If you know the cells are strings you can just cast
and then repeat either of the above (loop or
string.Join
).If items could be
null
,