There are four main access modifiers available in C#, but the two you'll be working with most often as a beginner are the following:
- Public: This is available to any script without restriction.
- Private: This is only available in the class they're created in (which is called the containing class). Any variable without an access modifier defaults to private.
The two advanced modifiers have the following characteristics:
- Protected: Accessible from their containing class or types derived from it
- Internal: Only available in the current assembly
There are specific use cases for each of these modifiers, but until we get to the advanced chapters, don't worry about protected and internal.
Two combined modifiers also exist, but we won't be using them in this book. You can find more information about them at https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/access-modifiers.
Let's try out some access modifiers of...