#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    9
    Rep Power
    0

    what's c#'s equivalent of vb.net's ctype


    this is a code from asp.net resource kit's step by step walkthru
    <%# CType(Container, ObjectListItem)("title") %>

    i am following the steps but doing it in c# rather than vb.net and i cant figure out what is this line's equivalent in C#. pls help
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    109
    Rep Power
    11
    In VB:
    Code:
    MySingle = CType(MyNumber,Integer)
    In C#
    Code:
    MySingle = (int)MyNumber;
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    14
    Rep Power
    0
    Originally Posted by arbalest
    this is a code from asp.net resource kit's step by step walkthru
    <%# CType(Container, ObjectListItem)("title") %>

    i am following the steps but doing it in c# rather than vb.net and i cant figure out what is this line's equivalent in C#. pls help
    VB:
    ...ctype(x, y)...

    C#:
    ...(y)x...

    I usually double-check stuff like this in the Instant C# VB.NET to C# converter (free demo version at www.instantcsharp.com).
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    9
    Rep Power
    0
    actually i've already tried
    <%# (ObjectListItem) Container["title"] %>

    it does not seem to work. this is the error im getting

    Compiler Error Message: CS0021: Cannot apply indexing with [] to an expression of type 'System.Web.UI.MobileControls.TemplateContainer'

    Source Error:



    Line 33: <AlternatingItemTemplate>
    Line 34: <TR bgcolor="#ccffff">
    Line 35: <TD><%# (ObjectListItem) Container["title"] %></TD>
    Line 36: </TR>
    Line 37: </AlternatingItemTemplate>
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    14
    Rep Power
    0
    Try:
    ...((ObjectListItem)(Container))["title"]...
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    9
    Rep Power
    0
    thanks that worked

IMN logo majestic logo threadwatch logo seochat tools logo