Thursday, 25 June 2026
The Powerful System.Environment
Friday, 24 April 2026
Why does TypeScript feel a bit C-Sharpy?
TypeScript was created by Anders Hejlsberg, a Danish software engineer, in 2012. He formerly created C# around the year 2000. He is also known for Turbo Pascal and Delphi, both extraordinary products in their time. Deservedly he is a Microsoft Technical Fellow (a list of whom appear here).
Saturday, 7 February 2026
Keep up to Speed with C# Language Design Discussions
Thursday, 20 November 2025
The Concept of C# Scripting (.csx files)
Sunday, 7 September 2025
The Jungle of Text Encoding
Dealing with textual data on the Internet is like navigating a jungle.
Without some normalisation, you need to get adept at handling multiple encodings.
System.Text is your partner here.
This holds the Encoding class, which has various useful properties.
Thursday, 1 May 2025
Dot net (.NET) MAUI for Dummies
Dot net (.NET) MAUI (Multi-platform App UI) is a cross-platform framework for creating native mobile and desktop applications with C# (and XAML optionally).
The upside is you just have one codebase which can be used to render UI on Windows, Android, iOS, macOS and Samsung Tizen.
For Windows, WinUI 3 is used as the native platform (this means it will work on Windows 10 version 1809 or later, and Windows 11).
Mermaid has evolved from multifarious UI technologies.
Tuesday, 13 August 2024
gRPC for .NET
The recommended library for using gRPC in .NET is grpc/grpc-dotnet under the Apache 2.0 license (The original implementation is now deprecated).
gRPC is a (language agnostic) remote procedure call framework designed for high performance.
gRPC is often used with protobuf with coding structured around .proto files explained here. One of the reasons for high performance is compact binary serialization of these so-called protocol buffers.
Common use cases include gRPC authentication (gRPC can converse with a variety of authentication systems), compression and other distributed communication scenarios.
It's first commit was made internal to Google in December 2013 and was made public on Github in 2015. Google was doing RPC with protocol buffers for years and years, but needed to expose APIs for public consumption. In 2017, gRPC was donated to the CNCF. More complex features were incorporated like Flatbuffer, which is for serialization - where you can use the data without full deserialization (originally used for games). Observability features have also been built into gRPC since its initial release.
gRPC is used by Netflix and Facebook and Google of course.
Sunday, 27 June 2021
ASP.NET Razor - What is it?
ASP.NET Razor is a (server-side) markup language, that allows you to embed server-based code into web pages (Visual Basic and C#).
Razor syntax is similar to PHP and Classic ASP.
The following Razor code outputs a series of list items.
<ul>
@for (int i=0; i<5; i++) {
<li>@i</li>
}
</ul>
The foreach loop is of course also supported in Razor.
Saturday, 8 September 2018
Using C# to Process Open XML Format Documents
Thursday, 3 May 2018
Object.GetHashCode
Tuesday, 24 April 2018
Calling a Base Class Constructor in C#
Naming Conventions for Abstract Classes in C#
(A famous example of prefix I usage "in the field" is the ubiquitous IEnumerable in System.Collections).
Some possible conventions that can be used (though some people oppose any prefix or suffix) -
- Prefix : Abstract
- Suffix: Base
Abstract classes cannot be sealed and they cannot be private, for obvious reasons. Abstract members cannot be labelled virtual as they are implicitly virtual. Also an abstract member cannot be static - perhaps less obvious.
The internal keyword in C#
Monday, 26 February 2018
Sunday, 3 July 2016
.NET Basics - What does void mean in C#? Is it the same meaning as in C++ or Java?
- void used as a method return type means that the method does not return a value. (Implementation-wise it is an alias for System.Void in mscorlib - which has no members except what it inherits from System.Object)
- void is also used to declare a pointer to an unknown type, when used in an unsafe context
Sunday, 22 May 2016
Roll your own MD5 implementation - here's how!
If you wish to implement an MD5 algorithm (commonly used to verify data integrity) in C# the "right way" to go about it is to inherit from class MD5.
public (abstract) class MD5: HashAlgorithm [From mscorlib and in System.Security.Cryptography]
public (abstract) class HashAlgorithm: IDisposable, ICryptoTransform
Brainchild of Yale Mathematician Ron Rivest!
The MD5 ("message digest") algorithm was designed in 1991 by Ronald Rivest (whose academic journey began with a Bachelors in Mathematics from Yale) as the successor to MD4, although execution speed is slower. It is described in RFC1321. It produces a 128 bit digest or "fingerprint" of the input data. That "fingerprint" can then be used to validate the integrity of downloaded data files.
The Avalanche Effect
A concept that comes up in discussions of MD5 and other related algorithms is the notion of the avalanche effect. This is a scenario where an input bit is allowed to impact two or more output bits. Berlin-born cryptographer Horst Feistel, whose research led to the formation of the Data Encryption Standard, or DES, in the 1970s, and gave his name to the Feistel cipher, coined the term.
The Idea of a One Way Hash Function or Cryptographic Checksum
To understand MD5 as a cryptographic checksum or one-way hash function, we should understand the basics of hash functions. A hash function converts a variable length input into a fixed length output (the former is known as the "pre-image" and the latter the "hash value"). The application is verification - to validate if a given "pre-image" is "likely" to be the same as the real "pre-image" the user is trying to validate. The key to a cryptographic hash, or one-way hash, is that it is difficult to create a "pre-image" that hashes to a particular value. In short, it is hard to spoof the true "pre-image".
Thursday, 12 November 2015
What Types of Thread Priority are there in .NET?
Monday, 21 September 2015
Find the Path for Embedded Resources using Reflection
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames()