mekUsermaBeab
New Member
I have the following class in a folder called Helpers in a simple MVC4 application:\[code\]namespace MyFirstMVC4.Helpers{ public static class Sample { public static int WordCount(this string str) { return str.Split(new char[] { ' ', '.', '?' }, StringSplitOptions.RemoveEmptyEntries).Length; } }}\[/code\]I then have the following code in a controller:\[code\]using MyFirstMVC4.Helpers;int x = "1 2 3 4".WordCount();\[/code\]The compiler throws an error saying name 'Helpers' does not exist in the namespace 'MyFirstMVC4'.If I removed the using MyFirstMVC4.Helpers statement the compiler throws an error saying string does not have a definition for WordCountThe Sample class, copied exactly the same as it is in my MVC4 works fine in a console application.I suspect this error is being caused by how MVC complies static classes. I have tried moving my Sample class to the App_Start folder and also adding the namespace of my Sample class to my Web.config.