Here are some Coding Kata videos of the Bowling Game Kata in various languages and environments. Some of them are dumb (no audio) just like good practice usually is. Note: it helps to know a bit about 10 Pin Bowling Scoring rules.
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 »
Reuse the VB.NET built-in Replace Function (Visual Basic) which works at least as of Visual Studio 2003 (.NET 1.1) and probably in Visual Studio 2002 (.NET 1.0, which I don’t have any more)
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.
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
}
Boy, was this Visual Studio .NET 2003 stuff a long time ago.
Bumped into this one:
---------------------------
Microsoft Development Environment
---------------------------
Visual Studio cannot start debugging because the debug target 'C:\develop\VS-2003\VS-2003-BASE\Source\AppTest\bin\Debug\AppTest.exe' is missing. Please build the project and retry.
---------------------------
OK
---------------------------
Indeed, Visual Studio was right: it didn’t understand the Release build existed like Visual Studio 2005 and up does: