Which code segment should you add?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application connects to a Microsoft SQL Server 2005 database.

You write the following code segment.

DataTable tbl = new DataTable();
tbl.Columns.Add("Price", typeof(double));
//Other columns added
//Fill data

You need to retrieve the maximum value in the Price column of the tbl DataTable.

Which code segment should you add?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application connects to a Microsoft SQL Server 2005 database.

You write the following code segment.

DataTable tbl = new DataTable();
tbl.Columns.Add("Price", typeof(double));
//Other columns added
//Fill data

You need to retrieve the maximum value in the Price column of the tbl DataTable.

Which code segment should you add?

A.
double maxPrice = (double)tbl.Compute("Max(Price)", "");

B.
double maxPrice = (double)tbl.Rows.Find("Max(Price)")["Price"];

C.
double maxPrice = (double)tbl.Select("Max(Price)")[0]["Price"];

D.
tbl.DefaultView.RowFilter = "Max(Price)";
double maxPrice=(double) tbl.DefaultView[0]["Price"];



Leave a Reply 0

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