Is it possible, in C#, to create extension methods on a class but restrict visibility/accessibility within a class? (e.g. Extension Method A on class M is only accessible within class Z)
Example:
class A
{
String foo = "";
String bar = foo.MakeMillionaire("arg");
}
In above example I want the extension method "MakeMillionaire" extending the String class only to be visible and accessible within class A. Can I do this somehow by defining the extension method in a static class within class A?
Edit: Trying a regular nested class yields "Error: Extension methods must be defined in a top level static class".