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:
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);
Answer A and C
Just A
C – cannot be as signature slightly different
https://msdn.microsoft.com/en-us/library/h9b85w22%28v=vs.110%29.aspx
If there were two choices then A & D
as signature with formats are
DateTime.TryParseExact Method (String, String[], IFormatProvider, DateTimeStyles, DateTime)
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.
why not B ?