.NET SqlDataReader Item[] vs. GetString(GetOrdinal())?

前端 未结 5 1228
感情败类
感情败类 2020-12-18 22:28

Using the SqlDataReader class, what, if any, are the functional differences between:

(string) dataReader[\"MyFieldName\"];

and

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-18 22:54

    In the first case you are casting which is ugly especially for value types (unboxing involved). Personally I always use the second and is what I would recommend you.

提交回复
热议问题