Question: Q1. (13 marks) You should create a console project named Q1 to do the following implementation. In the program below MyClass is a delegate.


Q1. (13 marks) You should create a console project named Q1 to do the following implementation. In the program below MyClass is a delegate. Define a method named callMe such that it is an extension method of the delegate MyClass when the following code fragments are run together with the method callMe, the integer 3 is dis- played as output on the console. You will receive 0 mark in this question if you change any code in the class MyWordCount and the class Program. using System; using System. Text; namespace Q1 { //(4 marks) //add necessary code below that declares the delegate MyClass // (9 marks) //add necessary code below that defines the method callMe public static class MyWordCount { } public static int numOfWords (StringBuilder sb) { } string[] words = sb. ToString().Split(' '); return words. Length; } public class Program { } public static void Main() { } MyClass k = MyWordCount.numOfWords; StringBuilder stb = new String Builder ("I am good"); Console.WriteLine( k.callMe (stb)); Console.ReadKey(); //Halts execution
Step by Step Solution
3.49 Rating (149 Votes )
There are 3 Steps involved in it
Heres the implementation of the callMe method as an extension method of the MyClass delegate csharp ... View full answer
Get step-by-step solutions from verified subject matter experts
