Author

Asynchronous programming with async and await (C#)

The async and await keywords in C# are the heart of async programming. By using those two keywords, you can use resources in the .NET Framework, .NET Core, or the Windows Runtime to create an asynchronous method almost as easily as you create a synchronous method. Asynchronous methods that you define by using the async keyword are referred to as async... » read more

Language Integrated Query (LINQ)

Language-Integrated Query (LINQ) is the name for a set of technologies based on the integration of query capabilities directly into the C# language. Traditionally, queries against data are expressed as simple strings without type checking at compile time or IntelliSense support. Furthermore, you have to learn a different query language for each type of data... » read more

C# Serialization

Serialization is the process of converting an object into a stream of bytes to store the object or transmit it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called deserialization. Uses... » read more

C# Interfaces

Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes. An interface represents a contract, in that a class that implements an interface must implement every aspect of that interface exactly as it is... » read more

C# Overriding

Overriding Members By default, a derived class inherits all members from its base class. If you want to change the behavior of the inherited member, you need to override it. That is, you can define a new implementation of the method, property or event in the derived class. The following modifiers are used to control... » read more

Sealed vs Abstract Class

Inheritance enables you to create a new class that reuses, extends, and modifies the behavior that is defined in another class. The class whose members are inherited is called the base class, and the class that inherits those members is called the derived class. However, all classes in C# implicitly inherit from the Object class that supports .NET... » read more

Anonymous Types

Anonymous types enable you to create objects without writing a class definition for the data type. Instead, the compiler generates a class for you. The class has no usable name and contains the properties you specify in declaring the object. To create an instance of an anonymous type: // sampleObject is an instance of a... » read more

Static Classes and Members

A static member of the class is a property, procedure, or field that is shared by all instances of a class. To define a static member: static class SampleClass { public static string SampleString = "Sample String"; } Console.WriteLine(SampleClass.SampleString); Static classes in C# have static members only and cannot be instantiated. Static members also cannot... » read more

Instantiating Classes

To create an object, you need to instantiate a class, or create a class instance. SampleClass sampleObject = new SampleClass(); // Set a property value. SampleClass sampleObject = new SampleClass { FirstProperty = "A", SecondProperty = "B" };

Nested Classes

A class defined within another class is called nested. By default, the nested class is private. class Container { class Nested { // Add code here. } } To create an instance of the nested class, use the name of the container class followed by the dot and then followed by the name of the... » read more