Which of the following is the DateTime method that is being included?

You work as a developer at ABC.com. The ABC.com network consists of a single domain named
ABC.com.
You have been tasked with creating an application allows users to enter time and dates. You are
writing code that includes a DateTime method, which converts the indicated string representation
of a date and time to its DateTime equivalent and returns a value that specifies whether the
conversion was successful.
Which of the following is the DateTime method that is being included?

You work as a developer at ABC.com. The ABC.com network consists of a single domain named
ABC.com.
You have been tasked with creating an application allows users to enter time and dates. You are
writing code that includes a DateTime method, which converts the indicated string representation
of a date and time to its DateTime equivalent and returns a value that specifies whether the
conversion was successful.
Which of the following is the DateTime method that is being included?

A.
TryParse(String, DateTime)

B.
TryParse(String, IFormatProvider, DateTimeStyles, DateTime)

C.
TryParseExact(String, String, IFormatProvider, DateTimeStyles, DateTime)

D.
TryParseExact(String, String[], IFormatProvider, DateTimeStyles, DateTime)

Explanation:



Leave a Reply 5

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


vivek

vivek

Option A and C

Reason

: Int32.TryParse(String, NumberStyles, IFormatProvider, Int32) method.

public static bool TryParseExact(
string s,
string format,
IFormatProvider provider,
DateTimeStyles style,
out DateTime result
)

if (DateTime.TryParseExact(dateString, “o”, CultureInfo.InvariantCulture,
DateTimeStyles.RoundtripKind, out dateValue))
Console.WriteLine(“Converted ‘{0}’ to {1} ({2}).”, dateString, dateValue,
dateValue.Kind);

vivek

vivek

Answer A and C

Manab

Manab

TryParse(String, DateTime) – Converts the specified string representation of a date and time to its DateTime equivalent and returns a value that indicates whether the conversion succeeded.
TryParse(String, IFormatProvider, DateTimeStyles, DateTime) – Converts the specified string representation of a date and time to its DateTime equivalent using the specified culture-specific format information and formatting style, and returns a value that indicates whether the conversion succeeded.
TryParseExact(String, String, IFormatProvider, DateTimeStyles, DateTime) – Converts the specified string representation of a date and time to its DateTime equivalent using the specified format, culture-specific format information, and style. The format of the string representation must match the specified format exactly. The method returns a value that indicates whether the conversion succeeded.
TryParseExact(String, String[], IFormatProvider, DateTimeStyles, DateTime) – Converts the specified string representation of a date and time to its DateTime equivalent using the specified array of formats, culture-specific format information, and style. The format of the string representation must match at least one of the specified formats exactly. The method returns a value that indicates whether the conversion succeeded.

https://msdn.microsoft.com/en-us/library/system.datetime_methods(v=vs.110).aspx

So for me the answer is A only.

Peter

Peter

why not B ?