.NET Core
.NET Core is compatible with a variety of operating systems, including Windows, Linux, and Mac OS. (Cross Platform)
.NET Core has built-in dependency injection.
.NET Core has support for microservices. , NET Core allows a mix of technologies that can be minimalized for each microservice.
.NET Core is an open-source platform.
.NET Framework
.NET Framework is compatible with Windows OS(operating system) only .
.NET Framework has no built-in dependency injection - need to use external libraries such as Ninject and Unity
.NET Framework it does not allow for the construction and deployment of microservices in multiple languages.
.NET Framework includes certain open source components.
Extension methods allow developers to add a method to existing types without changing the original source code. This allows them to extend the functionality of the method.
An extension method is a static method and uses the <this> keyword.
C# delegates are similar to pointers to functions, in C or C++.
A delegate is a reference type variable that holds the reference to a method
Delegates are mainly used in implementing the call-back methods and events.
Delegates can be chained together as two or more methods can be called on a single event.
Multicasting of a delegate.
Delegate objects can be composed using the "+" operator. A composed delegate calls the two delegates it was composed from.
Only delegates of the same type can be composed.
The "-" operator can be used to remove a component delegate from a composed delegate.
Using this property of delegates you can create an invocation list of methods that will be called when a delegate is invoked.
Generic is a concept that allows us to define classes and methods with placeholder
Generics allow you to define type-safe data structures, without committing to actual data types.
To define a class or method as generic, we need to use a type parameter as a placeholder with angle (<>) brackets.
String is present in System namespace.
A string object is immutable, meaning that it cannot be changed after it’s created.
Any operation that tries to modify the string object will simply create a new string object.
String is thread safe
StringBuilder is present in System.Text namespace.
StringBuilder object is mutable and can be modified
StringBuilder is not thread safe (not synchronized, not locked)
StringBuilder has overhead, so string is faster for limited concatenations.
If you are going to append or modify thousands of times (usually not the case) then StringBuilder is faster in those scenarios.
StringBuffer is a mutable (no StringBuffer in C#, its available in Java)
StringBuffer is thread safe (synchronized., locked)
StringBuffer is slower than StringBuilder as it need to lock and release locks for threads
In simple words String is an immutable. StringBuffer is a mutable and synchronized. StringBuilder is mutable but not synchronized.
Abstract classes: These provide a common definition for a base class that other classes can be derived from
Static classes: These contain static items that can only interact with other static items
Partial classes: These are portions of a class that a compiler can combine to form a complete class
Sealed classes: These cannot be inherited by any class but can be instantiated
const
They can not be declared as static (they are implicitly static)
The value of constant is evaluated at compile time
constants are initialized at declaration only
readonly
They can be either instance-level or static
The value is evaluated at run time
readonly can be initialized in declaration or by code in the constructor