Reference Types Consists of all class, array, delegate and interface types Stores the reference of an object Assignment just copies the instance not the object Reference type can be assigned to null, pointing to no object String (string) Object (object)
C# – Understanding Value Types
Types A type defines the blueprint for a value A variable denotes the storage location which can change overtime A constant always represents the same value Predefined types are types are supported by the compiler such as int and string The predefined bool type has exactly two possible values: true and false. There are two […]
C# – Conversions
Conversions A conversion always creates a new value from an existing one. Conversions can be either implicit or explicit. Implicit conversions happen automatically, and explicit conversions require a cast. For Implicit the compiler guarantee that it will succeed and no information is lost whereas explicit it is the opposite.
C# – Instance and Static
Instance and Static Instance members Data and function members that operate on the instance eg ints ToString() is a instance member of Integer class By default members in a type/class are instance members Static Members Don’t operate on the instance of the type Operate on the type itself Example using System; namespace Rextester { public […]
C# – Constructors and Instantiation
Constructors and Instantiation There are basically two types: Predefined types and Custom Type Predefined types It is the blueprint. It can be instantiated simply by using a literal such as 12 or “Hello world”. They are the types which are supported by the compiler. Examples such as int – represent a set of integers and […]
C# – Overview
Summary Is an object oriented paradigm consists of encapsulation, inheritance and polymorphism Unified Type system: all types share a common base type. Classes and Interfaces: comprised of Classes and Interfaces Properties, methods and events: properties – function members that encapsulate a piece of an objects state eg color, label text. Functons can be treated as […]
C# – Other Operators
Other Operators Most Common Operators Equality and Comparison Operators == : test for equality != : test for inequality Conditional Operators: && : AND || : OR Conditional operator (ternary operator) Takes three operands q? a: b The compound assignment operators are syntactic shortcuts that combine assignment with another operator. For example: x *= 2 […]
C# Unary Operators
Unary Operators These operators have higher precedence than multiplicative operators and lower precedence than the primary operators. +x Functions as unary or binary as addition if it is numeric or concatenation if one of the value is string -x Performs numeric negation. !x Logical negation operator ~x Bitwise complement. await (Asynchronous method) Awaits a Task. […]
C# Primary Operators
Operators There are many different kinds of operators defined in C#. The operators can also be overloaded to change their meaning when applied to user-defined type. Most common operators are (==, !=, , &, |) and generally used with enumeration types. Primary Operators These are the highest precedence operators. (Dot).Operator (x.y) Composed of 2 primary […]
C# – Nullable Types
Nullable Types Is a instance of the System.Nullable Struct Value type cannot be assigned a null value eg int i = null, but with Nullable struct you can store null with value types. All reference types are nullable but value types are not. Example Nullable<int> intValue = 5 ?? null; — can have interger value […]