Skip to main content
gamedev.net
🔒 Locked 🤖 Godot

Parameter "this" keyword : GetBottomCenter(this Rectangle rect)

Started by Stukey Dec 7, 2008 at 10:46 PM 0 replies 1.1k views
Original Post
Stukey
Stukey
I'm pretty new to C# and I noticed in the xna 3.0 platformer starter project the have the method: public static Vector2 GetBottomCenter(this Rectangle rect) { return new Vector2(rect.X + rect.Width / 2.0f, rect.Bottom); } I'm just wondering what declaring a parameter with "this" does, I looked up the keyword on msdn and it only shows the uses I know of, like accessing member variables using this., and when I google it, I just get a bunch of sites about different ways to pass parameter that don't mention using "this".
Trillian
Trillian
It's called "Extension methods" and its been introduced with C# 3.0. Googling "C# 3.0 extension methods" will provide you with all the info you need. You can also google "LINQ" for a better understanding of what this language feature permits.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.