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

Difference between an instance method and a static method

What is the difference? I don't quite understand what they are and what they do. On the video before the quiz he talks about it but I didn't understand. Any help is appreciated.

1 Answer

Fredrik Rönnehag
Fredrik Rönnehag
2,342 Points

Instance methods needs an instance of the class object. The class object needs to be created first. example:

var car = new Car();
car.Method();
// Creating the variable of the class Car to a new instance object named car.
// Calling the Method(); through the instance of car.

Static methods can be called without first creating an instance of the class.

Car.Method();
// Where Car is the class name.

// Sidenote: If the class is static you can't create new objects of that class.