HOTSPOT
You are developing an application in C#.
The application will display the temperature and the time at which the temperature was
recorded. You have the following method (line numbers are included for reference only):
You need to ensure that the message displayed in the lblMessage object shows the time
formatted according to the following requirements:
The time must be formatted as hour:minute AM/PM, for example 2:00 PM.
The date must be formatted as month/day/year, for example 04/21/2013.
The temperature must be formatted to have two decimal places, for example 23-45.
Which code should you insert at line 04? (To answer, select the appropriate options in the answer area.)

date format, it wrong it should be {0:mm/dd/yy}
3
2
No, but it’s difficult to see! Take a look at the wildcards:
‘MM’: would give the month.
‘mm’: gives MINUTES!!
1
0
correct answer : String.Format(“Temperature at {0:hh:mm} {0:d} temp {1:N2}”, DateTime.Now, 25);
O:t -represents the first character of AM/PM
0:mm/dd/yy – mm are minutes, MM are months
https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings#the-t-custom-format-specifier
0
1
>O:t -represents the first character of AM/PM
Not quite. There are also short format types.
DateTime.Now.toString(“t”) will return time in “HH:mm AM/PM” format
https://docs.microsoft.com/ru-ru/dotnet/standard/base-types/standard-date-and-time-format-strings
2
0
I worked out the correct code snippets:
string output = String.Format(“Temperature at {0:t} {0:d} temp {1:N2}”, DateTime.Now, 25);
8
1
The answer is
string output = String.Format(“Temperature at {0:t} {0:d} temp {1:N2}”, DateTime.Now, 25);
{0:d} refer to ShortDate
5
1
You are right
0
1
The answer is:
//modify the vlaue of en-us to Culture.
Thread.CurrentThread.CurrentCulture = new CultureInfo(“en-us”);
string msg = string.Format(“Temperature at {0:t} on {0:d} : {1:N2}”, DateTime.Now, 20);
3
0
Correct
Thread.CurrentThread.CurrentCulture = new CultureInfo(“en-us”);
string msg = string.Format(“Temperature at {0:t} on {0:d} : {1:N2}”, DateTime.Now, 20);
1
0
correct!
0
0
{0:t}
{0:d}
{1:N2}
3
1
if the year is 2013, then it must be “yyyy”. But there is no such Option.
0
0
{0:t}
{0:d}
{1:N2}
confirmed in Visual Studio:
string.Format(“time={0:t} date={0:d} temp={1:N2}”, DateTime.Now, 2)
——————————————
time=01:24 AM date=05/10/2016 temp=2.00
1
0
{0:d} and {0:t} is culture specific. For me this code print
time=23:43 date=14.02.2017
If I add before
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
then work correctly.
0
0
{0:t}
{0:d}
{1:N2}
0
0
string output = String.Format(“Temperature at{0:t} {0:d} temp {1:N2}”, DateTime.Now, 45);
{0:t}
{0:d}
{1:N2}
0
1
Wrong available answers!!!
Hour: The question gives this example 2:00 PM
-> 2 and not 02!
-> PM/AM
This can be achieved like this: “{0:h:mm tt}”. However, this is not in the list!
Month: It asks for teh formatt month/day/year (and not day/month/year)
This can be achieved liek this:{0:MM/dd/yyyy}”
2
0