I found myself having to remove the first line of a string quite often while working on a text parser in C#. I put together a simple function to do that for me, but coming from a PHP background, I have no idea where to put it since I can’t define a function outside a class. What’s a customary way of doing that in .NET? Do I create a static class to store my function?
Share
Yes, static helper classes are usually the way to do this.
Also, in C# 3 you can declare the method like this:
to make it an extension method. Then you can call it on any string as if the method was declared on the string type itself.