With the widespread popularity of Nuget, there is a package for everything in C#. Parsing CSVs are no exception, but this feels like overkill. Parsing a csv, tsv or any value separated file in C# is not complicated and can be done very easily by simply breaking up the string. It takes a little more…
CORS stands for Cross-Origin Resource Sharing. For most scenarios, what it does is let you use Javascript to make HTTP requests to a different domain. It is a very important security feature but is a useful thing to enable if you have the need for it. This guide will show you how to enable it…
Reading a File over FTP is a common scenario. Best case scenario, the file is JSON and you can very easily convert it to a C# object using the serializer. What happens when it is XML? Converting it to a model requires a little more work. Here is how to read an XML file from…
FTP (File transfer protocol) is a common method of storing and transferring files over the internet. Consuming a file from an FTP in C# is a very easy process and is something you may frequently find yourself needing to perform when dealing with online file transfers. The .NET Framework has built-in libraries to handle the…
I have a stream reader inside a using block of code in C#. Do I need to call reader. Close as part of this to close off the process and allow GC to clean up any memory or does it happen on its own? Here is the code that I am using. using (StreamReader reader…
Calculating the length of a string is a very simple thing to do in most programming languages. It is an action that you will find yourself needing to perform very often. Be it for validation, reporting or comparisons, knowing how to find how many characters a piece of text has using code is incredibly useful.…
When it comes to code readability, the initialiser syntax makes declaring C# objects very easy and clean to read. It also makes writing the code much faster since you do not need to be adding new constructors and lets you see what properties you have left to assign. But what about performance? Is one method…
I have a bit of an awkward example but I am trying to extract a value from a dictionary if the key contains a substring. I have this part working, but I need to know when it does not find a match. The response from this request does not seem to accept a null. Here…
I have a numeric string that contains leading zeros that I want to remove before I perform any comparisons with it on other objects. How can I trim an undefined number of zeros from a string without having to loop through the characters in the string and remove all the zeros that come first?