Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
|
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 2nd, 2004, 12:55 AM
Registered User
 
Join Date: Dec 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ChronicCode
Default Generic Type specification during runtime

is there any way of specifying the type of a generic class during runtime instead of at compile time?

my problem is that i have file several different versions of a file with each version having different properties and methods and it is not unitl compile time that i can findout what version of the file it is. Below is examples of the classes that i have

public class version1_0
{
   //example member
   public int total;
}

public class version2_2
{
   //example member
   public string extendedDesc;
}

public Gen<T>
{
   public T file;

   //other methods are here
}

public enum Versions
{
   v1, //represents the version1_0 class
   v2 //represents the version2_2 class
}

i want to add the generic class "Gen" to the class below using the _file variable and then set the type of the generic class Gen by the version that was passed into the constructor so i can specify the type of the Gen variable at compile time only at run time.
public class myFile
{
   private Gen??? _file;

   public myFile(Versions)
   {
      //set type of _file here by using Versions enum.
   }
}

is there any other way that i could go about solving this problem?

many thanks in advance.

Glenn





Similar Threads
Thread Thread Starter Forum Replies Last Post
Generic return type mega C# 4 November 30th, 2006 11:00 AM
Generic return type mega C# 2005 1 November 30th, 2006 07:27 AM
Runtime Error type 3146 Bruce Sexton Beginning VB 6 0 March 30th, 2005 09:33 AM
Generic Type specification during runtime ChronicCode General .NET 2 December 3rd, 2004 01:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.