Skip to content
Marvin Suen edited this page Apr 10, 2022 · 3 revisions

C# Notes

Useful syntax

Useful class syntax

namespace BlazorApp Defined the class is within the namespace "BlazorApp"

public class Todo {} within the namespace defines the name of the class "Todo"

public string? Title {get; set;} create a property called "Title"

Protected member is accessible within its class by derived class instances. Usually used for additional methods after class was initially defined.

abstract modifier indicates that the thing being modified has a missing or incomplete implementation. It can be used with class, methods, properties, indexers and events. Use the abstract modifier in a class declaration to indicate that a class is intended only to be a base class of other classes, not instantiated on its own.

virtual is used to modify a method, property, indexer, or event declaration and allow for it to be overridden in a derived class.

override modifier is required to extend or modify the abstract or virtual implementation of an inherited method, property, indexer, or event.

Useful functionsyntax

void is a return type used to specify that the method doesn't return a value.

Useful loop syntax

foreach is used to loop over a list<T>. i.e. foreach (var special in specials){} loops each special variable in a list called specials

for statement for (int i=0; i < List<T>.Count; i++){}

input => expression is called a lambda operator. It is a quick way to write a function

Clone this wiki locally