Which code segment should you insert at line 10?

An application receives JSON data in the following format:


The application includes the following code segment. (Line numbers are included for reference only.)


You need to ensure that the ConvertToName() method returns the JSON input string as a Name object. Which code segment should you insert at line 10?
A. Return ser.Desenalize (json, typeof(Name));
B. Return ser.ConvertToType(json);
C. Return ser.Deserialize(json);
D. Return ser.ConvertToType (json, typeof (Name));

microsoft-exams

5 thoughts on “Which code segment should you insert at line 10?

  1. another similar question with answer is:
    Return ser.Deserialize(json);

    for this question, nearest answer is:
    Return ser.Deserialize(json);

  2. Correct answer is A. Return ser.Desenalize (json, typeof(Name));

    There are only two possible usage of Deserialize:
    public T Deserialize(string input);
    public object Deserialize(string input, Type targetType);

    If we use C. Return ser.Deserialize(json), next error is returned by compiler:
    CS0411 C# The type arguments for method cannot be inferred from the usage.

  3. ser.Deserialize (json) ; returns an object which you need to cast to Name. Thus the answers shall be (Name)ser.Deserialize(json, typeof(Name)) or ser.Deserialize(json).

Leave a Reply

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


The reCAPTCHA verification period has expired. Please reload the page.