User Profile

Collapse

Profile Sidebar

Collapse
Wildhorn
Wildhorn
Last Activity: Feb 15 '11, 08:32 PM
Joined: Apr 19 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Wildhorn
    replied to Dynamic Cast
    No they do not inherit from the same type, but they all have string variables that need to be treated the same way.

    Anyway, I got a very "dirty" solution that I do not like much but that will do it for the moment. I made a function that receive the class object and with a switch case return an object of the good type and it works now, but it piss me off that I cant on the fly cast stuff when language like LUA allow such task...
    See more | Go to post

    Leave a comment:


  • Wildhorn
    replied to Dynamic Cast
    Because I essentially do the same treatment to 3 different class data, so I do not want to have to write 3 times 400 lines of code when only 1 cast need to be changed.
    See more | Go to post

    Leave a comment:


  • Wildhorn
    replied to Dynamic Cast
    This was just an example. I would not write you the whole thing because it does 400 lines long. But I need to dynamically cast something as a type I receive as parameter. Your thing for constructor is nice, but I need to cast something that already have variables saved into it.

    About:

    class Mammal
    class Dog : Mammal
    class Cat : Mammal

    Dog myDoberman = new Dog();
    Cat myTabby = (Cat)myDoberman ;//...
    See more | Go to post

    Leave a comment:


  • Wildhorn
    replied to Dynamic Cast
    It doesnt work, else I would not be asking for help. It just doesnt want to compile. It refuse to take a variable Type for a cast.

    In my arraylist, like I said, are homemade class.
    See more | Go to post

    Leave a comment:


  • Wildhorn
    started a topic Dynamic Cast

    Dynamic Cast

    Code:
    void Whatever(Type ClassType, ArrayList myArrayList)
    {
    ClassType myClass = new ClassType();
    myClass = (ClassType)myArrayList[0];
    }
    How can I make this work? ClassType is the type of an homemade class.
    See more | Go to post
No activity results to display
Show More
Working...