Color Of Code

  • Full Screen
  • Wide Screen
  • Narrow Screen
  • Increase font size
  • Default font size
  • Decrease font size

C# Miscellaneous

E-mail Print

Design mode

Gotcha: DesignMode property is not valid in constructor, use Load event instead.

Debugging code

To declare code that is active for a configuration only prefer using attribute against #ifdef's for more readable code: [Conditional("DEBUG")]

For displaying user string representation of classes in the debugger, prefer using the DebuggerDisplay attribute to overriding ToString as the latter is used by String.Format primarily:

[DebuggerDisplay("Count = {count}")]
class MyHashtable
{
public int count = 4;
}

Temporary File

using System.IO;
FileInfo tempFile = new FileInfo(Path.GetTempFileName());
...
tempFile.Delete();

Last Updated on Wednesday, 08 September 2010 02:40
You are here Code Snippets C# Miscellaneous