C# Fundamentals - Part 1
An Introduction to C#
Demo of C# program
Type example
All the value types are immutable
Classes and Objects
All the classes in .NET derives from System.Object
Demo with Circle and Square
Internal is default accessibility of class in c#
Private is default accessibility of member of class in c#
Demo of Abstract class
Here abstract keyword is used to prevent create objects for base class with new keyword
Virtual method dispatched based on type of the object
Regular method dispatched based on type of the variable
Method hiding:
we could achieve method hiding by adding virtual keyword at base class method and not adding override keyword at derived class.
Change the behavior:
to Change the behavior of base class method, we need to add virtual method at base class and override method at derived class
C# - Types
Demo of Methods parameters
IS Keyword:
Checks if an object is compatible with a given type. For example, the following code can determine if an object is an instance of the MyObject type, or a type that derives from MyObject.
Class1 a; Class2 b; if (o is Class1) { Console.WriteLine("o is Class1"); a = (Class1)o; // Do something with "a." }
Equal Method:
Determines whether the specified object is equal to the current object.
If the current instance is a reference type, the Equals(Object) method tests for reference equality, and a call to the Equals(Object) method is equivalent to a call to the ReferenceEquals method. Reference equality means that the object variables that are compared refer to the same object.
If the current instance is a value type, the Equals(Object) method tests for value equality.
Demo of Array
C# - Events, Properties, and Methods
Demo of Method:
Auto property:
Demo of Private Delegates:
Demo of Public Delegates:
Demo of Event Subscriber Delegates
Demo of constructor
C# - Flow Control and Exceptions
"Throw" will rethrow the exception with entire stack information.
"Throw ex" will rethrow the exception with stack information from current throw statement
C# and the CLR
Demo of Synchronous Programming
Demo of Asynchronous programming
Demo of Parallel programming API
Demo of Attributes
Default and Named Parameters in C# 4.0
C# and the DLR
A dynamic language is allowed to modify code and modify type at runtime.
Python, JS and Ruby does not have traditional Compiler for type checking but will check types at runtime
No comments:
Post a Comment