I am trying to change the behavior of a square bracket operator. Now my question is whether this is possible.
I know that I can create an extension method for String with something like this:
public static class StringExtension
{
public static char Substring(this string value, int position)
{
}
}
But how can I redefine the square bracket operator? This will not work:
public static class StringExtension
{
public static char this[this string value, int position]
{
}
}
How can I do that. Or is it possible?
source
share