开发者

Confusion in type conversion

i have confusion in type conversion please help me on below things.

开发者_如何学Go<%# int.Parse(Eval("VendorId").ToString()) %>,
<%# Eval("ListId").ToString()%>

what these two returns? Please suggest me on conversion.


The Page.Eval method returns a object (System.Object). So:

  1. int.Parse(Eval("VendorId").ToString()) is first evaluating the property expression VendorId (via DataBindiner.Eval), and then calling ToString(). The string conversion is required, because Int32.Parse accepts a string argument. You run the risk of having a null value returned here and passed to Int32.Parse though.
  2. Eval("ListId").ToString() is doing the same as above, but rendering the result of ToString() for the property expression Listid, instead of parsing it as an integer.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜