I have no idea what you mean by a "common" method.
An extension method is a method that extends a class without having to derive a whole new class to implement new functionality.
You need to create
public static class
(it can be given any name you want because it's static, and you don't have to instantiate it), and put your method in it:
public static class ExtensionMethods
{
public static string Append(this string text, string newText)
{
string result = text + newText;
return result;
}
}
You call it like this:
string x = "123";
x = x.Append("456");
After the call to
Append
, the variable
x will contain "123456".
Notice that the method MUST be
static
, and then notice the parameters. the first one indicates the object being extended, and the 2nd one is the text to be appended.
You really should learn how to use google, because hat's how you're going to learn the details about extension methods.