I am trying to convert the following in VB (which works fine):
DBConn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings(GlobalVariables.strConnection).ConnectionString
To C#:
DBConn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings(GlobalVariables.strConnection).ConnectionString;
However I get the following error in C#:
Non-invocable member 'ConfigurationManager.ConnectionStrings' cannot be used like a method.
What then would be the proper way to convert to C# ?
Since ConnectionStrings
is a collection with an indexer you have to use [...]
in C#
DBConn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings[GlobalVariables.strConnection].ConnectionString;
Here's the indexer you're using.