Posts on CSharp Concepts and Features
This is a collection of tutorials and posts on c-sharp language and its features.
(Rev. 31-Oct-2024)
Categories
|
About
|
|
Jun 2024 (43)
|
May 2024 (14)
|
Mar 2024 (1)
|
» →
Home
» ⟶ here
In this section
(C# 9.0) Record types vs class vs struct type, positional records and non-destructive mutation
12 Mar, 2021
THE CRUX: record types are meant for storing read-only, init-once data. They serve the purpose of ValueTypes, but in reality they are reference type . . .
Read ...
C#
(C# 9.0 "init" setter) Six Interview Questions and Answers on the init Property Accessor
23 Mar, 2021
Following are my top 6 interview questions on the "init" accessor introduced recently in C# 9. The answers have all been fully explained t . . .
Read ...
C#
C# Interview
Reasons why you should learn ASP.NET Core with Razor Pages
23 Nov, 2021
Following are some of the reasons that you can consider when deciding on learning ASP.NET Core. I think .NET Core has a good future and in the comin . . .
Read ...
ASP.NET Core
C#
ValueTask and Task - a Simple Explanation in Nutshell
29 Jun, 2022
If you already know of the Task type, and have now happened to meet a similar looking ValueTask, then you are likely interested in knowing more abou . . .
Read ...
C#
(C# Language) Expression-bodied Members
31 Aug, 2022
If a function consists of only one statement or expression, then the braces and the return keyword could be redundant. Thus, we can simplify such fu . . .
Read ...
C#
(C# Language) Null conditional (?. and ?[]) operators
01 Sep, 2022
An object reference might be null when your code calls a function or accesses a property. Programmers use an if-condition as a safety net and make a . . .
Read ...
C#
(C# Language) Main Method and Top Level Statements
04 Sep, 2022
Main method is the equivalent of the main method as we know in C language. It's the entry point of your program which means that it is the first . . .
Read ...
C#
(C# Language) Properties Auto-Implemented, Init, Readonly, Required
05 Sep, 2022
The concept of a property is the most widely used in dotnet programming. Properties provide setter and getter functions for validation of data befor . . .
Read ...
C#
(C# Language) Reference and ValueTypes
08 Sep, 2022
Value Types and Reference types are two types in C#. If you are familiar with C and C++, then you can think of reference types as that hold address . . .
Read ...
C#
(C# Language) Anonymous types and var Keyword
11 Sep, 2022
An anonymous type is described by a comma separated properties clubbed into curly braces. The properties are readonly. The corresponding data-type i . . .
Read ...
C#
(C# Language) Methods and ref, in, params and Named Args
12 Sep, 2022
Functions in C# are usually called Methods. They can exist inside a class, struct, record - but not globally outside. So every function, including t . . .
Read ...
C#
(C# Language) Delegates, Lambda Expressions, Action and Func Delegates
13 Sep, 2022
In this tutorial we learn about delegates that are a data-type for a function signature. In this context a function signature includes the return ty . . .
Read ...
C#
(C# Language) Inheritance and protected and sealed keywords
14 Sep, 2022
Inheritance in C# is similar to what we have in other object oriented languages. In this tutorial we take a short example to get introduced to the s . . .
Read ...
C#
(C# Language) Polymorphism in C#
15 Sep, 2022
This tutorial is for explaining a few programs that exhibit the idea of polymorphism. I won't be able to go into the philosophy of polymorphism. . . .
Read ...
C#
(C# Language) How and Why of static classes
28 Sep, 2022
A static class is a container for self-contained static functions that just operate on the input operators. The concept of a static class and static . . .
Read ...
C#
(C# Language) static and const Members
28 Sep, 2022
Only one copy of a static data member exists in the entire program. A const member behaves like a static, but it's value is marked as fixed and . . .
Read ...
C#
(C# Language) Interfaces
03 Oct, 2022
An interface is a collection of related functionality. An audio player is an audio player only if it implements the ability to play, pause, stop, et . . .
Read ...
C#
(C# Language) Generics
04 Oct, 2022
In this tutorial we take a hypothetical problem to build towards the concept of generics. First we explore a few bad solutions. Then we explain a pe . . .
Read ...
C#
(C# Language) class, record and struct
07 Oct, 2022
We expect you have a very general understanding of object oriented programming blocks like classes and structs. In this tutorial we have a quick loo . . .
Read ...
C#
(C# Language) Practice Exercise in C# - 1
10 Oct, 2022
Write a C# class called CData to hold a float type of quantity. This class also contains an enumeration of two members - Meter and Centimeter - to s . . .
Read ...
C#
(C# Language) Practice Exercise in C# - static and const
10 Oct, 2022
This exercise is an exercise just for the sake of practice in static and consts in a class. Create a class called CBankAccount that contains a stati . . .
Read ...
C#
(C# Language) Practice Exercise in C# - delegates
11 Oct, 2022
Create a class MyClock that contains only one public function "void Tick(Object?)". This signature matches the signature of the TimerCallb . . .
Read ...
C#
(C# Language) Practice Exercise on Property changed event and Lambdas
14 Oct, 2022
Create a class called MyNumber with a property called Number of Int32 type. This class should contain an event delegate that takes one argument of I . . .
Read ...
C#
(C# Language) Practice Exercise on Anonymous Types
16 Oct, 2022
We have to store four properties of a record - student id of string type and marks in three subjects of Int32 type. Inside main create an array of 1 . . .
Read ...
C#
(C# Language) LINQ - IEnumerable, yield and Enumerator
17 Oct, 2022
This tutorial introduces you to the IEnumerable interface and its practical significance. After that we discuss the internal workings of this interf . . .
Read ...
C#
(C# Language) LINQ - Select, Where, OrderBy and OrderByDescending
19 Oct, 2022
In this tutorial we learn the use of Select, Where, OrderBy and OrderByDescending functions provided by C# LINQ. A program has been used to explain . . .
Read ...
C#
(C# Language) LINQ - FirstOrDefault, Single, First, SingleOrDefault
19 Oct, 2022
In this tutorial we learn about FirstOrDefault, Single, First and SingleOrDefault extension methods available on an IEnumerable. Use FirstOrDefault . . .
Read ...
C#
(C# Language) LINQ - GroupBy
21 Oct, 2022
C# Linq provides a GroupBy extension method for grouping records on a common key. This tutorial starts with a brief introduction to the concept of g . . .
Read ...
C#
(C# Language) LINQ - Join
22 Oct, 2022
Two lists can be joined on common key or keys by using the Join extension method. The concept of a join in linq is exactly the same as in SQL of dat . . .
Read ...
C#
(C# Language) EF Core - Creating a Database
24 Oct, 2022
Database connectivity is required in almost every project. It is best done with the help of EF Core libraries. The good thing is that the steps for . . .
Read ...
C#
(C# Language) Practice Exercise on GroupJoin
25 Oct, 2022
Create a list of Category records with ID and Name as properties. Add 3 items to this list - (ID:1, Name:"For Men"), (2, "For Women&q . . .
Read ...
C#
(C# Language) EF Core - Complete CRUD Example Console Application
26 Oct, 2022
This tutorial continues from the previous tutorial where we created a database and a table in it. We shall now add a blog record to the table and sa . . .
Read ...
C#
(C# Language) Functional Techniques - Discards
27 Oct, 2022
Discards are denoted by an underscore. They can be thought of identifiers that receive an assignment, but the assignment is discarded and not availa . . .
Read ...
C#
(C# Language) Functional Techniques - Pattern Matching
28 Oct, 2022
Pattern matching is used to test an expression. In this tutorial we take various snippets to learn expression matching. One of the uses is to test i . . .
Read ...
C#
(C# Language) Strings and String Manipulation
30 Oct, 2022
In this tutorial we take common topics on strings, such as creating strings, on concatenation of strings, extraction of a substring, and truncation, . . .
Read ...
C#
(C# Language) Practice Exercise on String Manipulation
30 Oct, 2022
Suppose there is a string s = "aubcd123paqeaw". Write three programs (1) Write a program to count the number of 'a' in this string . . .
Read ...
C#
(C# Language) Statements and Expressions
03 Nov, 2022
The concept of statements and expressions in C# is exactly the same as in other programming languages. So, this tutorial is a review for the sake of . . .
Read ...
C#
(C# Language) Arrays - Jagged and Multi-dimensional
04 Nov, 2022
Array can be used to store many variables of the same type. An array can be of one dimension, can be of multiple dimensions and can even be a jagged . . .
Read ...
C#
(C# Language) Collections
05 Nov, 2022
A collection class holds objects. We have seen that arrays also hold objects. The size of an array is fixed at the time of creation, but collections . . .
Read ...
C#
(C# Language) Reflection
06 Nov, 2022
Reflection is used to obtain information about the functions, properties, events, fields of a given Type of dotnet. For example, we can use reflecti . . .
Read ...
C#
(C# Language) Asynchronous Task Programming
07 Nov, 2022
An application is often required to make database access, perform file read and write or contact internet for communication. All these tasks involve . . .
Read ...
C#
(C# Language) Exceptions and Errors
07 Nov, 2022
A function throws an exception on failure. The functions that are expected to fail are written inside try blocks with one or more catch blocks. Each . . .
Read ...
C#
(C# Language) Project Exercise on CSV Processing
11 Nov, 2022
A text file contains an unknown number of records. Each record is of the format ABCD,N where ABCD is the code of a supplier and N is a sequence of d . . .
Read ...
C#
C# Project on Classroom Voting Application
20 Nov, 2022
This project creates an HTTP Server on a Windows PC. The server presents an html page to a connecting client. The page contains html and javascript . . .
Read ...
C#
Step 1 - Create Models and Migrations (C# Project on Classroom Voting Application)
21 Nov, 2022
This is the first step of writing the code for the classroom voting application. In this tutorial we shall add a model class to hold voting data. We . . .
Read ...
C#
Step 2 - Set the HttpListener loop (C# Project on Classroom Voting Application)
23 Nov, 2022
This is the second step of writing our project on classroom voting application. We shall now set an http listener to listen and respond to requests . . .
Read ...
C#
C# 11 Projects with Step-by-Step Explanation and SOURCE CODE
26 Nov, 2022
Pay $10 and get all the following C# .NET Core Projects with Source Code. Code has been written with new C# features and syntax. Master the art of b . . .
Read ...
C#
(C# Language) Practice Exercise on Anonymous Types
16 Oct, 2022
We have to store four properties of a record - student id of string type and marks in three subjects of Int32 type. Inside main create an array of 1 . . .
Read ...
C#