I was trying to convert an object to a long in C# and tried it like this at first:
value = row.Cells[columnIndex].Tag as long;
I got the following error:
“The as operator must be used with a reference type (’long’ is a value type)”
The Solution
value = Convert.ToInt64(row.Cells[args.ColumnIndex].Tag);
Using Convert.ToInt64 will let you convert an object to a long.