Part 20 – C# Tutorial – Static and instance class members

Static and instance class members

Introduction

Static and Instance declaration was something that I found difficult to get my mind around when I first began programming and, after some searching, realized that there are not many places on the Internet that explain it in depth (or at least not to the point that makes any sense!).

Background

I recently had the opportunity to do some Technical Editing for one of Wrox Publishing’s upcoming books and had placed quite a lengthy comment in the manuscript related to Static vs Instance members. Unfortunately it was much too long for a side note and, at the suggestion of the author, I have decided to place that comment here, albeit expanded.

Using the Code

This code is functional in the aspect that it gets the point across of using Static and Instance members but it is up to you to expand upon this theory to make the code useful for anything. First, we need to understand the difference between static and instance members:

  • Static: Static members are shared with all objects of the class.
  • Instance: Instance members belong to the object that they are instantiated from.

[youtube https://www.youtube.com/watch?v=cFQLmHCguGs]

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *