Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Heres the implementation of the callMe method as an extension method of the MyClass delegate csharp ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started