Advertisement Jump to content
Sign in to follow this  
Stukey

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

This topic is 3692 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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".

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!