I've been messing around with Namespaces to improve the structure of my programs. I ran across a case where I wanted to use a public static method which returns a value without also calling its enclosing class. One method of doing this is by using an out parameter. So, let's say I have this code:
namespace Namespace1
{
namespace Namespace2
{
public class ClassName
{
public ClassName(Data data, out int AnInt)
{
AnInt = (int)data;
}
}
}
}
I can use this as follows:
Int AnInt;
Namespace1.Namespace2.ClassName(data, out AnInt);
But, let's say I want to get rid of the out parameter. Is there any way to is there any way to do this without exposing another level of the hierarchy, adding a using directive, or adding a Func<> delegate? Say:
Int AnInt = Namespace1.Namespace2.ClassName(data);
Datainstead ->int anInt = data.ToInt();