C# Fields and Properties
In this code snippet, we will learn how to implement fields and properties in C#. Fields are just normal variables but declared directly inside of a class. Even though you can make fields public, you shouldn’t(use a property instead). Only use fields locally inside the class.
C# Static Keyword
In this code snippet, we will learn about the static keyword in C#. The static keyword is used to indicate that a method, property, etc can be used without making an instance of its class.
C# Params Keyword
In this tutorial, we will learn how to use the params keyword in C#. The params keyword is used to define an array of input parameters for a method. Instead of explicitly defining every single one we can just pass in an array of parameters. As you can imagine when you have a lot of parameters this becomes very useful.
C# Access Modifiers
In this code snippet, we will learn how to use access modifiers in C#. Access modifiers are used to define the access level of types and members. The following access modifiers are available: public, private, protected, internal, protected internal, private protected.
C# Methods
In this code snippet, we will learn about methods in C#. A method is basically a code block with a name. It can have input parameters to pass data into the code block and it can have a return type to return data out of the code block. A method can be called by writing its name followed by a set of parentheses.
C# Generics
In this code snippet, we will learn about generics in C#. You can make generic classes, properties, methods, and parameters. If we make something generic this means it doesn’t have a type. Or better said the type is determined at compile time.
C# Class
In this code snippet, we’ll take a look at classes in C#. A class is like a blueprint to make an instance of an object. Inside a class, you can define class members like methods, properties, etc. Depending on the access modifier(public, private, …) set for each member we can control to who that specific member will be accessible.
C# Indexers
In this code snippet, we will learn how to implement indexers in C#. Indexers allow classes to be indexed just like arrays. To retrieve or set a value you just provide an index inside a set of square brackets just like you would for an array.
C# Ref Keyword
In this code snippet, we’ll what the ref keyword does in C#. Variables can be passed either by value or by reference. Usually, we do it by value meaning you pass just the value and not the variable itself. So, any changes made locally inside the method scope won’t be seen outside of the method scope.