Generics question

Trips

Well-known member
Joined
Aug 7, 2010
Messages
2,788
<span style="font-size:x-small <span style="font-size:x-small <font size="2
I have the following generic method:
</font>



<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff public<span style="font-size:x-small
<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff override<span style="font-size:x-small
<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff bool<span style="font-size:x-small Load<T>(T loadId)

{
<span style="font-size:x-small <font size="2

</font>



<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff if<span style="font-size:x-small (loadId
<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff is<span style="font-size:x-small
<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff string<span style="font-size:x-small )

{
<span style="font-size:x-small <font size="2

</font>



<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff return<span style="font-size:x-small loadByNetworkId(loadId
<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff as<span style="font-size:x-small
<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff string<span style="font-size:x-small );

}
<span style="font-size:x-small <font size="2

</font>



<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff **--> else<span style="font-size:x-small
<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff if<span style="font-size:x-small (loadId
<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff is<span style="font-size:x-small
<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff int<span style="font-size:x-small )

{
<span style="font-size:x-small <font size="2

</font>



<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff return<span style="font-size:x-small loadByPersonId(loadId
<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff as<span style="font-size:x-small
<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff int<span style="font-size:x-small );

}
<span style="font-size:x-small <font size="2

</font>



<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff else<span style="font-size:x-small

{
<span style="font-size:x-small <font size="2

</font>



<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff return<span style="font-size:x-small
<span style="font-size:x-small; color:#0000ff <span style="font-size:x-small; color:#0000ff true<span style="font-size:x-small ;

}
}
<span style="color:#0000ff **--> This line returns an error that says the as operator may only be used with a reference type. But some of the MSDN docs clearly show using is with the int type. What else could I be doing wrong?
<span style="color:#0000ff Thanks!
<span style="color:#0000ff Kurt



View the full article
 
Back
Top