Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with generic
Message
From
18/07/2007 08:17:39
 
 
To
17/07/2007 19:09:55
Victor Acosta
Independent Programmer.
San José, Costa Rica
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 2.0
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01241343
Message ID:
01241432
Views:
28
Hi, Victor.

>This is the Scenario
>
>I am creating an instance of a object derivated from a special collection in that way:
RegionCollection myregioncollection = new RegionCollection().Load();
//load fill the collection with data from a table, each collection represents objects , each object is a row //from the table.
>
>Then I am saving the object into a session to allow other web pages recover the object and then perform some actions.
>
Session[“mycollection”]= myregioncollection;
>
>NOW I am in other web form and I NEED to recover the object saved in session like this;
>
? Mylocalcollection;
>Mylocalcollection = Session[“mycollection”];
>
>?= the type I don’t know.
>
>BUT, I need first to declare the type of Mylocalcollection which is unknown, since I can have several types of object saved into the session (each table of my system represents a type). If I don’t know the type I can not initialize my local object.
>
>How can I solve this situation with generics or whatever.

Well, the question is: what's the type of the objects you are loading into RegionCollection? If they are all from different types, then you have a design problem, most probably. Can you provide more details about what's the purpose of this collection?

>Note: This is solved in C# with the type VAR, but for now I am in C# 2

Not at all. var only lets the compiler infer the type from the right side of the expression, but you still have to know what it is to be able to use it.

Regards,
Previous
Reply
Map
View

Click here to load this message in the networking platform