CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • ADO.NET Data Services in the .NET Framework
  • Visual C++ Programming: What's new for MFC library in VC++ 2010?
  • Microsoft Visual Studio LightSwitch and What It Can Do For You
  • Displaying Files and Folders in a GridView

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > .NET Programming > C-Sharp Programming
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    C-Sharp Programming Post questions, answers, and comments about C#.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old August 31st, 2009, 06:24 PM
    code? code? is offline
    Member
     
    Join Date: May 2006
    Posts: 306
    code? is on a distinguished road (20+)
    Type Conversion Help

    Okay, I want to know if you can do something like this, I have a parser and I'm trying to have less and less switch blocks and/or repetitive code.

    So something like this. It errors out but can I do something similar?

    Code:
    object i = 5;
    int j = 6;
    
    (i.GetType())i += j;
    Reply With Quote
      #2    
    Old August 31st, 2009, 06:43 PM
    monalin monalin is offline
    Member
     
    Join Date: Jul 2006
    Posts: 297
    monalin has a spectacular aura about (125+)monalin has a spectacular aura about (125+)
    Re: Type Conversion Help

    Short answer is no. You cannot dynamically cast an object from a System.Type object. Now maybe if you can show us a sample of your switch blocks and/or repetitive code we can try to find another solution.
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > .NET Programming > C-Sharp Programming


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 11:08 PM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.