none
An appropriate date/time format. Exam 70-483 RRS feed

  • Question

  • I was just looking thru a 70-483 exam preparation questions here www.exam-labs(dot)com/exam/70-483 (sorry, I couldn't insert link because my account is not verified yet)

    And I failed on the very second question. But once I tested it in VS I found out that the answer there is wrong. 

    So you don't have to visit the website I've copied the question here:

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

    private void DisplayTemperature(DateTime date, double temp) {
    	string output;
    	// insert answer here
    	string message = output;
    
    }




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

    And the answer is:

    output = string.Format("Temperature at {0:t} on {0:dd/mm/yy} {1:N2}", date, temp);

    I tried to do the same in Visual Studio and see what I got:

    Here is my code

    class Program {
    		static void Main(params string[] args) {
    			
    			DisplayTemperature(DateTime.Now, 25);
    			ReadLine();
    		}
    		private static void DisplayTemperature(DateTime date, double temp) {
    			string output;
    			output = string.Format("Temp at {0:t} on {0:dd/mm/yy} {1:N2}", date, temp);
    			string message = output;
    			WriteLine(output);
    		}
    	}


    And this was the output:

    Temp at 16:06 on 11.06.18 25,00

    Temp at 16:06 on 11.07.18 25,00

    Temp at 16:06 on 11.08.18 25,00

    And so on. The month field incremented on every app launch

    Today is actually April 11th, 2018.

    So I have two questions now

    1) What happens to the month? Why is it incrementing?

    2) Why does it insert dots instead of forward slashes?

    p.s. If I replace "mm" with capitalized "MM" and replaced "yy" with "yyyy" everything is fine but this answer is not on the list. 

    Can somebody explain it to me, please?

    If the real Microsoft exam is like this one, it's gonna be very easy to fail on it


    • Edited by caseyryan Wednesday, April 11, 2018 3:32 PM
    Wednesday, April 11, 2018 9:16 AM

Answers

All replies

  • I think that you should note the remark, which is displayed in the footer: “Materials do not contain real or actual questions and answers…”.

    Wednesday, April 11, 2018 10:16 AM
  • anyway, my question is not about it
    Wednesday, April 11, 2018 11:57 AM
  • The one who made the exam thinks probably that everybody is living in the US. That is the only country beside Coca Cola cultures where this date time format is used. In your case when you are not living in the USA I would complain at Microsoft, 

    You can force your program to do if it is only used in the USA by setting the culture to that. 


    Success
    Cor


    Wednesday, April 11, 2018 12:04 PM
  • FAIK 'm', 'mm' is not month - it is minute.
    https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

    With kind regards
    Wednesday, April 11, 2018 1:05 PM
  • You're right! Thanks :) 

    Wednesday, April 11, 2018 3:32 PM
  • Hi caseyryan,

    If your question has been solved, please mark the useful reply as answer. This will make answer searching easier in the forum and be beneficial to community members.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 12, 2018 7:44 AM
    Moderator
  • Yes, sorry :) I must have marked and quickly unmarked it as answer for some reason
    Thursday, April 12, 2018 4:56 PM