Which line of code should you use?

You use Microsoft .NET Framework 4 to develop an application. The configuration file contains the
following code segment.
<configuration>
<connectionStrings>
<add name=”AdventureWorksLT”
connectionString=”Data Source=SQL01;
Initial Catalog=AdventureWorksLT;
Integrated Security=True;”
providerName=”System.Data.SqlClient”/>
</connectionStrings>
</configuration>
You need to retrieve the connection string named AdventureWorksLT from the configuration file.
Which line of code should you use?

You use Microsoft .NET Framework 4 to develop an application. The configuration file contains the
following code segment.
<configuration>
<connectionStrings>
<add name=”AdventureWorksLT”
connectionString=”Data Source=SQL01;
Initial Catalog=AdventureWorksLT;
Integrated Security=True;”
providerName=”System.Data.SqlClient”/>
</connectionStrings>
</configuration>
You need to retrieve the connection string named AdventureWorksLT from the configuration file.
Which line of code should you use?

A.
var connectionString = ConfigurationManager
.ConnectionStrings[“AdventureWorksLT”].ConnectionString;

B.
var connectionString = ConfigurationManager
.ConnectionStrings[“AdventureWorksLT”].Name;

C.
var connectionString = ConfigurationManager
.AppSettings[“AdventureWorksLT”];

D.
var connectionString = ConfigurationSettings
.AppSettings[“AdventureWorksLT”];

Explanation:



Leave a Reply 0

Your email address will not be published. Required fields are marked *