Judging by that screenshot, designKey[0] is not a string, it's an int. Because it is not directly castable to a string, using as string on it will result in a null. Think of as as a form of cast that doesn't crash if it doesn't work out. This doesn't work out:
object o = 123;
string s = (string)o;
It crashes like this:
Run-time exception (line xx): Unable to cast object of type 'System.Int32' to type 'System.String'.
as doesn't crash, it just returns null for casts that don't work;
If you really want it as a string, call .ToString() on it. Otherwise, cast it to an int(or long/whatever it is)
foreach(DataRow designKey in designFolioList.Rows)
{
var currentDesignKey = (int)designKey[0];
var currentDesignKeyStr = designKey[0].ToString();
}
.ToString() works because object has .ToString(), and so does int (by way of override). ToString()ing an int, turns it into a string representation of itself: 123 -> "123"
as. You probably want.ToString()if you want it as a stringdesignKey[0]. Why are you trying to convert it to a sting? It isn't a string.