C# Dynamic Keyword
Dynamic allows you to save any data type into a variable or pass any type into a method/return any type from a method.
Dynamic allows you to save any data type into a variable or pass any type into a method/return any type from a method.
In this code snippet, we will take a look at DateTime in C#. DateTime is used to represent dates and times in code. The DateTime class contains many useful methods to manipulate the date(formatting the date, adding/subtracting years, months, days, hours, …). Let’s have a look at the code below to see how to use DateTime.
It’s hard to remember everything you learn over the years especially if you don’t use it very often. That’s why I think it’s good to have a compilation of cheatsheets, reference books or other types of resources like blog posts/videos/PDFs. So in this post, I will “bookmark” some useful software engineering resources and cheatsheets for myself(or anyone else who stumbles upon this post).
In this code snippet, we’ll learn how to upload files with Javascript. We will use the input HTML element and set its type to “file”. Then javascript can be used to retrieve the selected file from the input element and send it to the backend. You can use whatever you want for your backend: nodejs, PHP, Java or in this case I will use a C# Azure function.
In this tutorial, we will take a look at string interpolation in C#. To enable string interpolation put the $ character before the string. Now variables in brackets can be put straight into a string. This is a bit more convenient compared to splitting up as string, putting the desired variables in between the strings and than concatenating it all together.
In this tutorial, we will take a look at string literals and the @ character in C#. In C# the @ character can either be used to make reserved keywords available as variable names or it can be used to make a string literal. A string literal takes everything in the string literally. For example, you do not have to escape a \ with \\ . Your string can now also span multiple rows in the editor. This can be useful when making SQL statements or HTML, XML, …
In this code snippet, we will take a look at break and continue in C#. break is used to break out of a code block. If done in a loop it will essentially stop the loop from executing. continue is used to inside a loop to skip the current iteration.
In this code snippet, we will take a look at the goto keyword in C#. goto is used to move the control of your program to a label you define beforehand. This can be useful to get out of nested loops, if statements or any nested code blocks in general. You can even make a DIY loop or method using the goto keyword 😁(But you should of course use the regular loops and methods).
In this code snippet, we will take a look at variable scope and code blocks in C#. A code block is the space between two { }. Variables can be considered out of or in scope depending on whether they are accessible or not from a particular code block.
In this code snippet, we will take a look at the TPL(Task Parallel Library) in C#. If you read some of my other posts on threading you will know that it can be quite complicated and laborious for the developers to implement parallelism into their programs(deadlocks, cancellation, thread pooling, getting data back from the thread, …). The Task Parallel Library(TPL) takes care of a lot of these things and or makes them easier manage.