Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialNicolas Bastos
4,209 PointsJust by looking at System.DateTime.AddDays() how would I know if it is an instance method or a static method?
What the title says, I am very confused. I kinda get the difference but dont understand how you could find out just by looking at that. Thankyou!
1 Answer
Steven Parker
231,269 PointsYou'd need to see it being used, or check the documentation.
Just the name doesn't help, but if you see it used in code you could recognize an instance method because it would be stuck onto a class variable name. A static method would be used with just the name.
Otherwise, you could check the documentation. If the definition syntax does not include the word "static", then it is an instance method. And in the examples you will see it stuck onto a class variable name when it is used.