mpen
mpen

Reputation: 282825

Get class that method was defined in?

Given a MethodInfo object, how can I get the Type object for the class that it was defined in?

Upvotes: 40

Views: 10858

Answers (3)

mpen
mpen

Reputation: 282825

Oh... I think it's DeclaringType.

Upvotes: 6

nos
nos

Reputation: 229058

You can get the Type the method belongs to with the DeclaringType property

Upvotes: 5

LukeH
LukeH

Reputation: 269298

You're looking for the DeclaringType property:

Gets the class that declares this member.

Upvotes: 60

Related Questions