Archive for the ‘C# 2.0’ Category
Posted by jpluimers on 2015/02/10
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Delphi 5, Delphi 6, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2015/02/04
Thanks Stefan Glienke for pointing me to NCrunch for Visual Studio:
It intelligently runs automated tests so that you don’t have to, and gives you a huge amount of useful information about your tested code, such as code coverage and performance metrics, inline in your IDE while you type.
–jeroen
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Software Development | Leave a Comment »
Posted by jpluimers on 2015/01/27
A few libraries for writing and/or reading CSV files in .NET:
Most of the above links come from these SO questions:
Together with the links from my previous CSV post If you think CSV is easy; think again that should get everyone going.
–jeroen
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, CSV, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2014/12/24
Once every while you still do WinForms work, and bump into something you hadn’t bumped into before.
This time it was trying to set ForeColor = Color.Red on a ReadOnly TextBox for displaying error messages:
- Using a TextBox means the user can still copy the text to the clipboard.
- Using a Red foreground draws enough attention (it’s was an app with a really busy user interface).
When setting a TextBox from ReadOnly = false to true sets the BackColor from SystemColors.Window (usually white) to SystemColors.Control (usually light grey), and leaves the ForeColor to SystemColors.WindowText (usually black).
Setting ForeColor = Color.Red (funny there is a plural in SystemColors but not in Color) it doesn’t display it as such:
To my surprise, the TextBox had ReadOnly text (you could copy, but not modify it), which showed with a a grey (SystemColors.Control) BackColor and a black (SystemColors.WindowText) ForeColor: the defaults for a ReadOnly TextBox, not using my ForeColor = Color.Red;
I vaguely remembered there was some odd way of solving this, but since I hadn’t written a blog article about it back then (somewhere around .NET 1.x or 2.0 I didn’t have a blog yet), I was glad that Cheetah posted this answer on StackOverflow: Read the rest of this entry »
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Color (software development), Development, Software Development, VB.NET, VB.NET 10.0, VB.NET 11.0, VB.NET 7.0, VB.NET 7.1, VB.NET 8.0, VB.NET 9.0, Visual Studio 11, Visual Studio 2002, Visual Studio 2003, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, Visual Studio and tools, WinForms | Leave a Comment »
Posted by jpluimers on 2014/12/16
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development, VB.NET, VB.NET 10.0, VB.NET 11.0, VB.NET 7.0, VB.NET 7.1, VB.NET 8.0, VB.NET 9.0 | 2 Comments »
Posted by jpluimers on 2014/11/04
Normally you would not want to use a reserved word as an identifier. But sometimes it can be very convenient, for instance for a code generator that wraps remoting calls or does ORM.
Both Delphi and C# have an escape for this:
The prefixes are to tell the compiler knows you really know what you are doing, and are using a reserved word as an identifier.
The cool thing: in the Run Time Type Information (Delphi) or Reflection (C# and VB.NET) you will see the names without the prefix.
Some examples from StackOverflow: Read the rest of this entry »
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Conference Topics, Conferences, Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 8, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Development, Event, Jon Skeet, Software Development, VB.NET, VB.NET 10.0, VB.NET 11.0, VB.NET 7.0, VB.NET 7.1, VB.NET 8.0, VB.NET 9.0 | Leave a Comment »
Posted by jpluimers on 2014/09/09
Bosak posted an interesting piece of code on StackOverflow last year. His particular code was in C#, but it does not matter what kind of compiler you use:
Sometimes a compiler will complain about unreachable code, for instance when it thinks a function never returns a value.
But you know the program logic does.
Simple solution: When you have code that never should be reached: throw an appropriate exception.
public static int GetInt(int number)
{
int[] ints = new int[]{ 3, 7, 9, int.MaxValue };
foreach (int i in ints)
if (number <= i)
return i;
return int.MaxValue; //this should be unreachable code since the last int is int.MaxValue and number <= int.MaxValue is allways true so the above code will allways return
}
The last return could be replaced like this, as proposed by Matt Houser: Read the rest of this entry »
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2014/07/02
I only need it every once in a while, so finding the right links and tips to help me usually takes too much time.
So here is a small list to get started:
Keywords: CLR, SOS.DLL, WinDbg, mscordacwks.dll, PSSCOR4
Some tips: Read the rest of this entry »
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Debugging, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2014/06/26
Interesting: about a year and a half ago, the Nikon SDK C# wrapper project started ad sourceforge.
Basically, it allows you to integrate the operation of your Nikon DSLR into your .NET projects.
It has some very interesting features:
- Control your Nikon DSLR via USB
- Capture Jpeg and Raw images directly to system memory
- Receive ‘Live View’ images
- Record Video
- Query and change camera settings (Exposure, Aperture, ISO, etc.)
- And much more…
Downloads: Nikon SDK C# Wrapper – Browse Files at SourceForge.net.
–jeroen
via: Nikon SDK C# Wrapper | Free Security & Utilities software downloads at SourceForge.net.
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2014/05/08
It is almost 3 years that Ostemar wrote an interesting answer on Stack Overflow to the question
Why does .NET use banker’s rounding as default? – Stack Overflow.
Few people (even many programmers don’t!) know about rounding and how it can influence software, let alone what bankers rounding does so lets set a few things straight first.
Rounding matters. Depending on the kinds of software you write, it matters a little, or a lot.
For instance, in these categories, it can matter an awful lot:
- Financial applications
- Statistical applications
Bankers rounding means rounding half even. Which means that #.5 will round to the even number closest to #.
In bankers rounding, 1.5 rounds to 2, 3.5 to 4 as does 4.5, -1.5 rounds to -2, -3.5 to -4 as does -4.5.
This is called “unbiased” because for reasonable distributions of y values, the expected (average) value of the rounded numbers is the same as that of the original numbers.
This is contrary to what the majority of people are accustomed to: Round half away from zero is taught in most countries (even for the Dutch, despite the alias “Dutch Rounding” for round half to even).
Round half away from zero rounds 1.5 rounds to 2, 3.5 to 4 and 4.5 to 5. Negative numbers round like this: -1.5 rounds to -2, -3.5 to -4 as does -4.5 to -5.
This is only free of overall bias if the original numbers are positive or negative with equal probability.
In short, .NET uses bankers rounding because it follows the IEEE 754 rounding rules.
This was his answer: Read the rest of this entry »
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, .NET CF, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | 3 Comments »