Strongly typed parameters to your Main function

I have written my fair share of console applications in .NET. They are possibly the most common type of application that I write. Whether it is to test a new language feature, a library from NuGet or a simple script to run ad-hoc tasks – console applications are my goto application type. And now that we can install .NET applications as global .NET Tools, they are very useful to write and redistribute small utilities.

However one of my bugbears is handling of arguments. A typical .NET …


(Note: To skip to the absolute bare-bones of getting up and running with C# scripting go to the TD;LR section…or stay on — because “the journey is the reward ”.)

Yes, it’s true, your favourite programming language is also a scripting language. Well, C# has had native scripting support, powered by Roslyn, for a while now.

In this article, however, we will not look into the details of the C# scripting language. Instead, we will look at how you can use VSCode as an efficient and productive environment to write C# scripts in.

Before we get into the ‘how’ let's…


Introduction

In C#, as in most programming languages, we work widely with variables, without almost ever having to think about them. They are in some ways the building blocks of our code and their ubiquity can blind us to the subtle complexities.

Photo by Susan Holt Simpson on Unsplash

In this article, I want to try and examine what the humble ‘variable’ is and try and peer under the hood — a tiny little bit.

So, what is a variable?

Defining a variable is deceptively easy

A variable is a symbol that refers to a storage location.

Most modern programming languages allow us to use convenient symbols to represent storage locations in source…


Some Rhyme…No reason

Logos of top programming languages

Python
The language everyone has their eyes on,
These days everyone loves Python.

AI, ML or data science — it will take you places,
Just be careful to mind your spaces.

But is it because it is good, or because it is free,
who knows — but, don't use version two, use three!

Java
In Java write once, they said, and it will run anywhere,
And so they did — without a reason or care.

It now runs banks, governments and our phones,
It runs our cars, fills taxes, gives out loans.

It used to be new, cool, funky, but…


Closures originated from the world of functional programming, but as programming languages have evolved recently they have been liberally borrowing ideas from other languages and paradigms. In this post, we will look at closures through the lens of C#.

Closures are like those optical illusions that seem normal when you first look at them, however, their magic unfolds on closer inspection.

Photo by Randy Jacob on Unsplash

Consider this c# code snippet,

void Main()
{
var a = foo();
bar(a);
}
public Action foo()
{
int i = 100;
Action a = () => Console.Write($"{i} ");
return a;
}
public void bar(Action a)
{
a();
}

ilias shaikh

Software Engineer.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store