C# Using Static Directive (Static Import)C# using static directive helps us to access static members (methods and fields) of the class without using the class name. If we don?t use static directive, we need to use class name to call static members each time. It allows us to import static members of a class into the source file. It follows a syntax that is given below. C# using static directive syntaxIn the following example, we are not using static directive. We can see that, to access static method of Math class, class name is used. C# Example without using static directiveOutput 12 javatpoint.com In the following example, we are using static directive in the source file. So, it does not require class name before calling the method. C# Example with using static directiveWe can see, it produces the same result even after removing the type from the function call. Output 12 javatpoint.com Next TopicC# Exception Filters |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India