Home About

All posts tagged with "C#"

C# (C-sharp) is a general-purpose programming language using strong typing, It was developed around 2000 by Microsoft and used on the .Net platform.

← Newer Posts Page 2 of 6 Older Posts →

C# - how to inject, mock or stub DateTime for unit tests

In this post I will demonstrate how you can stub the DateTime struct in your unit tests. Most commonly the method DateTime.Now or DateTime.UtcNow »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on C#, Unit tests, Test doubles 16 May 2020

What is the lock statement (monitor) in C#? and what you should look out for

In this post I will show how the lock statement in C# works and what you should look out for when using it. It is well »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on C#, Lock, Thread 25 April 2020

Asp.net websockets - sending messages back and forth between client and server

My previous post on websockets on how to stream messages to a client has become quite popular. I felt that I left this halfway when I »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on C#, Websocket, ASP.NET, .Net core, .Net 14 March 2020

Asp.net core - How to make a controller action receive text/plain content as a string - which also works in swagger

I have recently had to make an endpoint in asp.net core that receives text/plain content - or raw text as you may call it. »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on Swagger, C#, .Net core 29 February 2020

C# - How to make a list of tuples with named values

I found it hard to find a webpage showing a simplistic way to create named value tuples in a list. Most of the examples I could »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on Valuetuple, C#, .Net core, .Net 22 February 2020

Why boolean names should be positive and not negative

This post may seem like sub optimization to some, however high readability of code makes code easier to understand and thereby change. In my opinion, great »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on Code readability, C#, Java, Programming 08 February 2020

.Net core HttpClient - how to set content-type for a request

For some reason I can never remember how to make a POST or PUT request with a content-type other than JSON or XML. For JSON and »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on HttpClient, .Net, .Net core, C# 01 February 2020

C# - How to read all lines in a file to an array or list

In C# it is quite convenient to read all files to an array. You can use the method ReadAllLines() from the File class, all it needs »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on C#, File, List 04 January 2020

C# - Trim() String using a string instead of a single char

Today I found that C# does not have a built in method for trimming strings using another string. The built in method for trimming strings does »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on C#, .Net 31 October 2019

xUnit - how to check if a call does not throw an exception

If you are moving from NUnit to xUnit, you will likely encounter the absence of the DoesNotThrow method in xUnit. You are looking for something that »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on C#, XUnit, Unit tests 27 October 2019
← Newer Posts Page 2 of 6 Older Posts →
Rss
Twitter
LinkedIn
profile for Peter Rasmussen at Stack Overflow, Q&A for professional and enthusiast programmers
Peter Daugaard Rasmussen - developer, Consultant, Blogger © 2021 Cookie policy