C# Miniprojects

DigiClock1.DigiClock

First Miniproject is my digital clock with transparent background. See the sourcecode and exec- file here. After start of the exe- file go with mouse DigiClockWithPUover a number and with right click open the popup menu. There you can define the display / content, select „stay on top“ or close application. If you click with left mouse button on a digit you can shift and change position.

2. Comma problem

In many C# application I have to convert ASCII – text in a textbox into floating point numbers. DotNet offers some conversion functions like „Convert.ToDouble“ or „Double.TryParse“, but both functions use the separators defined in the Windows of the used PC. If you exchage textfiles with these numbers between different PCs then it could happen, that a german textfile with comma as decimal separator is read by a US – PC with dot as separator. Then this caused reading errors. In my function „ConvertToDouble(xyz.Text, ref h1)“ it first tests, which sign is used as separator. Then the wrong separator is replaced by the correct one. This works also together with used thousand- separators. The only problem is the use of only one separator in a number. Then this is read as a decimal separator.  Examples:
1,000,000.00 is read as one million
1.000.000,00 is also read as one million
1.000 and 1,000 are both read as one
Use this code snippet

Hinterlasse eine Antwort