If you’re looking for a 1 liner that is equivalent to this.GetType()
for static methods, try the following.
Type t = MethodBase.GetCurrentMethod().DeclaringType
Although this is likely much more expensive than just using typeof(TheTypeName)
.
More Related Contents:
- What is the difference between String and string in C#?
- How to create a new object instance from a Type
- String was not recognized as a valid DateTime ” format dd/MM/yyyy”
- What is the difference between String and string in C#?
- Convert String to Type in C# [duplicate]
- Method can be made static, but should it?
- Generics in C#, using type of a variable as parameter [duplicate]
- Testing if object is of generic type in C#
- .NET Integer vs Int16?
- How to call generic method with a given Type object? [duplicate]
- Getting a System.Type from type’s partial name
- .NET : How do you get the Type of a null object?
- C# – how to determine whether a Type is a number
- Determine if a type is static
- How to switch between “possible” type of an object? [duplicate]
- Checking if an object is a number
- Is there a way to force a C# class to implement certain static functions?
- Are nullable types reference types?
- How do I check if a type provides a parameterless constructor?
- Can I import a static class as a namespace to call its methods without specifying the class name in C#?
- What is the “base class” for numeric value types?
- Transactions in .net
- SQLite Database Locked exception
- InvalidProgramException / Common Language Runtime detected an invalid program
- Where in memory are nullable types stored?
- Convert binary string into integer
- Create web service proxy in Visual Studio from a WSDL file
- EF5 Getting this error message: Model compatibility cannot be checked because the database does not contain model metadata
- Why only literal strings saved in the intern pool by default?
- What do ref, val and out mean on method parameters?