Download a file in C# from a .cshtml

C Sharp

To download a file in C# from a .cshtml file is a lot simpler than you think. All you need to download a file in C# mvc is a HttpPost method that can create bytes of your file. Then you use return File(), and there you go! In the controller you can do other stuff […]

C# display decimal without trailing zeros

C Sharp

C# display decimal without trailing zeros!How to display decimals in C# without trailing zeros? Well, there are a couple of options. First of all, how many decimals do you want to show? Do you want to show 0, 1, 2, etc. Well the easy way to do it is just like this! In the code […]

Transform a Web.config file in Azure Devops

Dot Net

So do you need to transform a web.config file in azure devops? So here is how you do it! First of all, add the task named “File transform”. After that you select “XML transformation”. The important parts are the transformation rules and how you set up the config files in Visual Studio. So what you […]

Create an Excel File With a Picture in C#

C Sharp

So how do you create an excel file with a picture in C#? It is a actually fairly simple. If you use the correct tools! By using Microsoft Office 16.0 Object Library you can add a image to your excel file with 1 simple line. And by using the Microsoft library to create your excel […]

Foreach loop in C# – Simple use

C Sharp

Foreach loop in C# – SimpleForeach is in my opinion the best way to iterate a List of objects in C# and it’s super logical. On the left side of the declaration you have what is inside the List. And on the right side you have the List. Like this: As you see above, we […]

For loop in C# – Simple how to use

C Sharp

For loop in C# – Simple how to useFor is in my opinion one of best way to iterate a List/Array of objects in C#. When you need to keep track on what row in the iteration you are on. There are 3 parts of the For loop declaration, the “counter”, the break expression, and […]

Add object to List in C# – Simple use

C Sharp

Add object to List in C# – Simple. The first thing you need to do is define the list with new List<object>(). When you have your list, all you need to do is list.Add(object). One common use case for adding to a list in C# is doing it in a loop, for example if you […]

Reverse FOR loop in C# – A quick look

C Sharp

The reverse FOR loop in C# are useful if you need to iterate a List or array backwards. Without first having to reversing it, which can be time and memory consuming. Therefore, by using a reversed FOR loop you can traverse a list, array or string backwards in a simple way. So if you take […]

This website uses cookies. By continuing to use this site, you accept our use of cookies.