PrepAway - Latest Free Exam Questions & Answers

Which code should you insert at line 04?

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.)

PrepAway - Latest Free Exam Questions & Answers

Answer:

13 Comments on “Which code should you insert at line 04?

  1. sv1slim says:

    Don’t forget that DateTime format also includes time not only date. Should be something like that:
    var output = string.Format(“Temperature at {0:hh:mm} on {0:dd/mm/yy} is {1:N2}”, date, temp);




    0



    1
  2. Caret says:

    Temperature at 21-03-2017 12:39:19 on 12:39 21-03-2017 – {0} on {0:t} {0:d}
    Temperature at 23,453 on 12:39 21-39-17 – {1} on {0:hh:mm} {0:dd/mm/yy}
    Temperature at 23,45 on 12:39 03-21-17 – {1:N2} on {0:hh:mm} {0:MM/dd/yy}




    0



    0
  3. Lord Vader says:

    {0:t} displays argument 0 with short times(2:15pm)
    {0:d} displayed argument 0 with short date(3/14/2017)
    {1:N2} displays argument 1 with 2 decimal

    Jiping Wang says:
    May 10, 2016 at 10:14 am
    {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



    1

Leave a Reply