I'm not sure what the "Default" part of the code represents, so I'm leaving it out.
Atleast two different ways: 1. Create an alias for the fully qualified name of the class within the using statement as follows: --- using MyClass = MyBusinessLayer.MyStaticClass; --- This would be in the Imports region of the code. Then call it in your code as follows: --- MyClass.MethodA(); --- For details, see http://msdn.microsoft.com/en-us/library/sf0df423(loband).aspx 2. If you're using C# 3+, you can create an extension method in your static class named With... and then use the lambda to achieve a similar effect. However, the point to evaluate is the design of the class itself. Instead of the current design, perhaps your class should be as follows : --- namespace MyBusinessLayer { class MyClass { public void DoStuff() { MethodA(); MethodB(); MethodC(); } } } --- Calling code only calls the DoStuff() method. On Aug 18, 4:03 pm, Steffen Sommer <[email protected]> wrote: > Hi, > > Im facing an issue since some time now. > > I have a static class with lets say 20 static methods. When using this > class in a form for instance i do something like: > > MyBusinessLayer.MyStaticClass.Default.MethodA(); > MyBusinessLayer.MyStaticClass.Default.MethodB(); > MyBusinessLayer.MyStaticClass.Default.MethodC(); > ... > MyBusinessLayer.MyStaticClass.Default.Save(); > > Or anything... My Question is: > Is there a way to shorten this? > > I mean like the using statement inline, but static classes have no > instances and they have no Dispose() implemention. > using (Font f1 = new Font()) > { > .... > > > > }- Hide quoted text - > > - Show quoted text -
