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:
int.Parse(Eval("VendorId").ToString())
is first evaluating the property expressionVendorId
(viaDataBindiner.Eval
), and then callingToString()
. The string conversion is required, becauseInt32.Parse
accepts a string argument. You run the risk of having a null value returned here and passed toInt32.Parse
though.Eval("ListId").ToString()
is doing the same as above, but rendering the result ofToString()
for the property expressionListid
, instead of parsing it as an integer.
精彩评论