K
keithb
I'm trying to understand C# type casting. The following code will not
compile unless I Cast item to a String.
private static String myData;
foreach (DataRow row in MyTable.Rows)
{
foreach (Object item in row.ItemArray)
{
myData = item;
}
}
However when I use plus-equal instead of equal it compiles without casting
as shown in the code below.
foreach (DataRow row in MyTable.Rows)
{
foreach (Object item in row.ItemArray)
{
myData += item;
}
}
Can someone explain the difference?
compile unless I Cast item to a String.
private static String myData;
foreach (DataRow row in MyTable.Rows)
{
foreach (Object item in row.ItemArray)
{
myData = item;
}
}
However when I use plus-equal instead of equal it compiles without casting
as shown in the code below.
foreach (DataRow row in MyTable.Rows)
{
foreach (Object item in row.ItemArray)
{
myData += item;
}
}
Can someone explain the difference?