T
Tony Johansson
Hi!
As you can see I have defined namespace ConnectionStringDemo in the console
app. From Main I call method GetSection that returns type
ConnectionStringDemo.ValuesHandler.
I just wonder why is it not possible to skip the namespace becuse I have
already declared it and just write
ValuesHandler val =
(ValuesHandler)ConfigurationManager.GetSection("MyFirstSectionGroup/MyFirstSection");
When I do so I get the following exception.
An unhandled exception of type 'System.InvalidCastException' occurred in
ConsoleApplication7.exe
My question is just why ?
I mean as long as I have declared the namespace in my case
ConnectionStringDemo I have automatically access to it.
using ConnectionStringDemo;
class Program
{
static void Main(string[] args)
{
ConnectionStringDemo.ValuesHandler val =
(ConnectionStringDemo.ValuesHandler)
ConfigurationManager.GetSection("MyFirstSectionGroup/MyFirstSection");
}
}
//Tony
As you can see I have defined namespace ConnectionStringDemo in the console
app. From Main I call method GetSection that returns type
ConnectionStringDemo.ValuesHandler.
I just wonder why is it not possible to skip the namespace becuse I have
already declared it and just write
ValuesHandler val =
(ValuesHandler)ConfigurationManager.GetSection("MyFirstSectionGroup/MyFirstSection");
When I do so I get the following exception.
An unhandled exception of type 'System.InvalidCastException' occurred in
ConsoleApplication7.exe
My question is just why ?
I mean as long as I have declared the namespace in my case
ConnectionStringDemo I have automatically access to it.
using ConnectionStringDemo;
class Program
{
static void Main(string[] args)
{
ConnectionStringDemo.ValuesHandler val =
(ConnectionStringDemo.ValuesHandler)
ConfigurationManager.GetSection("MyFirstSectionGroup/MyFirstSection");
}
}
//Tony