Category: C# Tips

C# equivalent to VB val() function

Although VB had it’s limitations, it was damn easy to filter an input string for a numerical value. Here is how to do it in C#. You’ll need to use System.Text.RegularExpressions in the header private static int VBVal(string sInput) {

Posted in C# Tips

Image Editing in C# – Contrast

When attempting to get machines to process images you sometimes run into noise problems. Filters are regularly applied first to clean them up. Editing the contrast of an image changes its dynamic range. In its most basic form, it will

Posted in C# Tips

Image Editing in C# – Greyscale

I’m in the process of writing some code to detect the stars in astromical images. One of the filters I need to apply to an image is to convert it to greyscale. Conversion to greyscale is relatively straightforward – The

Posted in C# Tips

TLEs – Calculation of the Julian Day Number (JDN)

This post is part of a series on understanding the meaning behind the values contained in a Two Line Element set, or Keplerian Elements. The main article is here. Calculation of the Julian Day Number (JDN) Julian day numbers are

Posted in Astronomy, C# Tips

Code: Shortest distance between any two line segments

I recently needed to find the shortest distance between any two line segments in 3D space. I managed to find some C++ code online at which I converted to C#. It’s fairly easy to use. If you only need

Posted in C# Tips

SHA256 and higher in SQL Server

As part of a new project I’m doing, I needed to use hashes. A good source of information on hashes is available from wikipedia. SQL has the built in function HASHBYTES but this only supports up to the SHA128 algorithm

Posted in C# Tips, SQL Tips, Tips