I wish to call some methods only for the list of a class.
Although the extensive method could be defined only for List<>, it's not able to access the private field inside the target class (see code) because it is treated as a totally different class type.
I know in C++, friend
could set some methods access to the private data. But C# can't
So, Is there any elegant pattern to share the private data between T and List?
e.g. :
class Solid
{
private Faces[] f;
...
}
public static class SolidExtensions
{
public static Solid Merge(this IList<Solid> Solids)
{
//Get all faces from Solids. //not possible
return Build(faces);
}
}