Does C# has feature like Java’s static imports?
so instead of writing code like
FileHelper.ExtractSimpleFileName(file)
I could write
ExtractSimpleFileName(file)
and compiler would know that I mean method from FileHelper.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Starting with C# 6.0, this is possible:
However, previous versions of C# do not have static imports.
You can get close with an alias for the type.
Alternatively, change the static method to an extension method on the type – you would then be able to call it as: