c# error

This line:

var conString = ConfigurationManager.ConnectionStrings["LocalSqlServer"];

gives me the error


The type or namespace name 'var' could not be found (are you missing a using directive or an assembly reference)

=====
This line


vbnetcoderAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
np:
string conString = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ToString();

Open in new window

0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
try:

string conString = ConfigurationManager.ConnectionStrings["LocalSqlServer"];
0
 
vbnetcoderAuthor Commented:
It tells me that I can't exlicitly convert it to string
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
Todd GerbertIT ConsultantCommented:
Just to expand slightly...the C# keyword var was introduced with Visual Studio 2008, you won't be able to use it with earlier versions.
0
 
Carl TawnSystems and Integration DeveloperCommented:
And it should be:
string conString = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;

Open in new window

0
 
vbnetcoderAuthor Commented:
ty
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.