C# Basics – Classes – Part 11

We introduce classes in C# programming language in this tutorial.


Andraz Krzisnik
C# Basics – Classes – Part 11

Classes

Class is basically a container of functions. It can be a separate file or it can be written in the same file as your main project file. We can also create a custom object with properties we define.

public class myClass
{
    private string myString;
    public myClass(string someString)
    {
        myString = someString;
    }
}

We briefly touched the subject of access keywords that determine how accessible is some object or a variable.

  • An object, when set to private, is accessible only within the curly brackets it’s been declared in.
  • An object, when set to public, is accessible from outside the curly brackets it’s been declared in.
  • An object, when set to protected, is accessible only within the curly brackets it’s been declared in and in it’s inherited classes.
Download Examples Next Chapter
Show Comments (0)

Comments

Related Articles

C# Basics

C# Basics – Functions – Part 10

Functions We’ve been writing simple programs so far. But when things get more complicated, writing it all into one block of code could become hard to read. We can use functions...

Posted on by Andraz Krzisnik
C# Tutorial

C# Tutorial: How To Create Image Zero Padding

Zero padding an image is useful when we’re convolving it with a filter of certain size. How much padding should we use depends on how big our filter is. What is the purpose...

Posted on by Andraz Krzisnik