PrepAway - Latest Free Exam Questions & Answers

How should you complete the relevant code?

DRAG DROP
You are developing a class named ExtensionMethods
You need to ensure that the ExtensionMethods class implements the IsUrl() method on
string objects.
How should you complete the relevant code? (To answer, drag the appropriate code
segments to the correct locations in the answer area. Each code segment may be used
once, more than once, or not at all. You may need to drag the split bar between panes or
scroll to view content.)

PrepAway - Latest Free Exam Questions & Answers

Answer:

4 Comments on “How should you complete the relevant code?

  1. PaulC says:

    the correct code would look like this:

    public static class ExtensionMethods
    {
    public static bool IsUrl(this String str)
    {…}

    Explanation:

    extensions must be in a static class as it kind of a shared source of extension methods. you dont instantiate the class.

    the key word “this” is simply a syntax how you tell the compiler, that your method IsUrl is extension for the String object. You can read it like:




    1



    0

Leave a Reply