Dennis Forbes on Software and Technology   Subscribe to RSS


About the Author
Dennis Forbes Dennis Forbes is a Toronto-based software architect. While focused primarily on the .NET and SQL Server worlds, Dennis frequently ventures outside of this comfort zone into game development and image processing. He has been published in several industry magazines, has been quoted in the Wall Street Journal and has been interviewed by NPR.

He is a vice president and lead software architect at an innovative New York City hedge fund back-office services firm.

Dennis has been working on solutions for the financial, telecommunications, and power generation markets for over 15 years.




The Feed Bag

 
Tuesday, September 27 2005

Here's a super high-value C# console application that's going to corner the GUID creation market.

using System;
using System.Windows.Forms;

namespace yafla.yaflaGuid 
{
 class GuidToClipboard 
 {
  [STAThread]
  static void Main(string[] args)
  { 
   string guidString = System.Guid.NewGuid().ToString("B");
   Clipboard.SetDataObject(guidString, true); 
   Console.WriteLine(guidString);
  }
 }
}

I'm constantly in need of GUIDs ("Can you spare a GUID please, sir?"), and generally use guidgen.exe, included with the Visual Studio tools. The problem with it, however, is two fold - it's too many steps, and it includes a line feed on the end of the notepad copied guid. Annoying.

Finally I made the incredibly complex console application that you find above, generating a GUID (with no tailing linefeed), copying it to the clipboard for use elsewhere, and then spitting it out on the console (if I didn't want the console, err, "feature", this would be one unique line over the standard console wizard output). \

I'm even benevolent enough to include a binary (requires .NET 1.1 Framework. Interesting that the compiler padded it up to 16KB - will have to look at why it did that). 

Enjoy this revolution in GUID creation.

Reader Comments

Add Comment

Name *:

Email Address:

(your email address is not displayed)
Website:

Comment *:


Dennis Forbes