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

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

Answer:



Leave a Reply 4

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


MarcoJacob

MarcoJacob

1 and 3

Anon

Anon

Why 3? Should it not be 4? Someone please explain

PaulC

PaulC

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:

ASV

ASV

14 and 50 almost the same.