locked
Need to convert the non-generic classes and collections into generic classes RRS feed

  • Question

  • Hi,

        I have a dll containing a large set of classes with non-generic and i need to convert it to generic classes(i.e)by using List,Dictionary etc...I tried and converted some of the classes,it compiles without error but while run-time it causes exceptions and errors....Even i tried to find how to fix the errors,but the execution flow takes too long and goes tedious...so i need some help to convert and execute it correctly...

    • Edited by Jesica Thursday, October 16, 2008 7:17 AM
    Wednesday, October 15, 2008 6:12 AM

Answers

  • You can't simply change the core by making all the classes generic. The reason for this is that the library using your core will not compile any longer (or throw exceptions like in your case).

    Whenever you change the code into generic classes, you need to define the variables that use the same type as generic too. Aren't there unit tests in your project that you can use?
    Geert van Horrik
    • Proposed as answer by Geert van Horrik Wednesday, October 15, 2008 7:13 AM
    • Marked as answer by Jesica Wednesday, October 15, 2008 7:19 AM
    Wednesday, October 15, 2008 6:29 AM

All replies

  • You can't simply change the core by making all the classes generic. The reason for this is that the library using your core will not compile any longer (or throw exceptions like in your case).

    Whenever you change the code into generic classes, you need to define the variables that use the same type as generic too. Aren't there unit tests in your project that you can use?
    Geert van Horrik
    • Proposed as answer by Geert van Horrik Wednesday, October 15, 2008 7:13 AM
    • Marked as answer by Jesica Wednesday, October 15, 2008 7:19 AM
    Wednesday, October 15, 2008 6:29 AM
  • Hi,
       Thanks for you guidance...I proceed as you said by changing the class variables also(Already i might have changed many of the variables to generic type)...could you please provide any sample or tutorial references regarding this?


    Thanks ,
    arunmanick...
    Wednesday, October 15, 2008 7:11 AM
  • Wednesday, October 15, 2008 7:13 AM