Quick 500 - Creating an instance of a Class automatically by using imports?
Posted on 2005-03-09
Hi, i'm still a little new to .Net so this might be an impossible question,
I've been looking at the Microsoft Configuration Block recently, to use it you basically add the reference to your project and type in:
Once you do this, you can instantly use the ConfigurationManager and other Namespaces without having to Create an instance of them...
i.e. Obj_ConfigManager = Microsoft.Practices.EnterpriseLibrary.Configuration.GetInstance
I was wondering if there is a way that i can also supply an 'Automatic' instance of a Class in this manner, i.e. at the moment, with the Structure that i define, i have to basically declare a new instance of it somewhere before i can start hacking at it's properties.
So for this example, could someone tell me by (in a new referenced project if possible) if i can automatically allow my main project to start using the following example class without having to go:
Obj = new <instance>
Here's a simple class with a single property
Public Class Configuration
'Sets the Class Objects up as a Property to return
Public Property Config_Database() As Configuration_Database
Return CType(ConfigurationManager.GetConfiguration("DatabaseInfo"), Configuration_Database)
Set(ByVal Value As Configuration_Database)