Hi
Error - Cannot convert Lambda expression to delegate type because it is not a delegate type
Below is the code
dgvWindows.BeginInvoke(() =>
{
if (!_isRunning)
return;
var row = dgvWindows.Rows[dgvWindows.Rows.Add()];
row.Cells[0].Value = handle;
row.Cells[1].Value = _driver == null ? string.Empty : _driver.Title;
row.Cells[2].Value = state;
row.Cells[3].Value = $"{_duration.Hours:00}:{_duration.Minutes:00}:{_duration.Seconds:00}";
row.HeaderCell.Value = row.Index + 1;
BeginInvoke(() => Text = $"YouTube Tools - {row.Index + 1}");
});
Thanks
Jithu ThomasPosted Apr 7, 2024, 11:25 AM
Jithu ThomasPosted Apr 7, 2024, 11:23 AM
i think the same has been resolved in the below mentioned thread.
https://www.c-sharpcorner.com/Forums/cannot-convert-lambda-expression-to-type-sharp39delegatesharp39
Ramco RamcoPosted Apr 7, 2024, 6:32 AM
Hi Tahir
Sorry the code was below but error is same
Thanks
Tahir AnsariPosted Apr 7, 2024, 6:16 AM
In this case, it seems like
BeginInvokeis expecting a delegate type, but the lambda expression() => Text = $"YouTube Tools - {row.Index + 1}"doesn't match that delegate type.assuming
BeginInvokeis a method that takes anActiondelegate: