✅ Extension Methods

this is an extension method that i have read in the docs , my question is when i use this extension method as below code in that case the this keyword bind the sentence string inside method as i did not pass any parameter correct?
c#
namespace StringExtnsion
{
    public static class WordCountExtinsion
    {
        //this is used to bind the method to the main class 
        public static int WordCount(this String str)
        {
            string[] strings = str.Split(new char[] { ' ' , '?' });

            return strings.Length;
        }
    }
}

c#
string? sentence = "My Name Is Mina?mina";

Console.WriteLine(sentence.WordCount());
Was this page helpful?