Question: Extension method C# - a) Create a console app and implement an extension method - CountWords() for built-in class StringBuilder to count the number of
Extension method
C#
- a) Create a console app and implement an extension method - CountWords() for built-in class StringBuilder to count the number of words contained in a StringBuilder object. [5 marks] a [You need to add a separate StringBuilderExtensions.cs file containing class - StringBuilderExtensions, and adding CountWords method in there.] b) In the class file, containing Main() method, you will be testing your method. [2.5 marks] For example, if a StringBuilder object strobj = "This is to test whether the extension method count can return a right answer or not, the number of words contained in strobj is 16. Or if strobj = You can define extension methods for user defined types as well as predefined types, then it will return the result - 14
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
