В коде ....
void OneWay()
{
System.Data.SqlClient.SqlDataReader reader = null;
int i = reader.GetInt32(0);
}
void OtherWay()
{
System.Data.SqlClient.SqlDataReader reader = null;
int i = (int)reader[0];
}
В ИЛ
.method private hidebysig instance void OneWay() cil managed
{
.maxstack 2
.locals init (
[0] class [System.Data]System.Data.SqlClient.SqlDataReader reader,
[1] int32 i)
L_0000: nop
L_0001: ldnull
L_0002: stloc.0
L_0003: ldloc.0
L_0004: ldc.i4.0
L_0005: callvirt instance int32 [System.Data]System.Data.Common.DbDataReader::GetInt32(int32)
L_000a: stloc.1
L_000b: ret
}
.method private hidebysig instance void OtherWay() cil managed
{
.maxstack 2
.locals init (
[0] class [System.Data]System.Data.SqlClient.SqlDataReader reader,
[1] int32 i)
L_0000: nop
L_0001: ldnull
L_0002: stloc.0
L_0003: ldloc.0
L_0004: ldc.i4.0
L_0005: callvirt instance object [System.Data]System.Data.Common.DbDataReader::get_Item(int32)
L_000a: unbox.any int32
L_000f: stloc.1
L_0010: ret
}
Итак, ИЛ отличается, но я сомневаюсь, что между ними есть какая-то заметная разница. Возможно, после миллиона итераций вы увидите разницу, но маловероятно.