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 trial

C# C# Objects Methods Documentation

Nicholas Wallen
Nicholas Wallen
12,278 Points

Explain Like I Am Five: Why is AddDays() an instance method but DateTime() is static?

This is extra confusing to me. Can someone explain this in the simplest of terms? Not jargon?

1 Answer

Steven Parker
Steven Parker
231,198 Points

Instance methods only work on an instance.

So it makes sense that AddDays would be an instance method because you need an instance to add the days to. You can expect instance methods to either get something from, or do something to, the instance that they are applied to.

On the other hand, all constructors (like DateTime) have to be static because you use them to create an instance, and therefore you don't already have one that you could apply them to.

Does that help make it clear?