Tsallaka zuwa abun ciki
Justice Tech School

Extension Methods

A static method with this on the first parameter adds a method to an existing type.

Example
Console.WriteLine("hello".Shout());

static class StringExt
{
    public static string Shout(this string s) => s.ToUpper() + "!";
}

Exercise

Extend a type.

Shout( string s)

Quiz Test

Where do extension methods live?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.