Showing posts with label c#. Show all posts
Showing posts with label c#. Show all posts

Tuesday, August 4, 2009

Constructors for VB.NET Modules


Did you know that you can have a constructor on a module? I first got the notion to try this after thinking about static constructors in C#. In C#, you can do something like this:

class Class1
{
private static int _magicNumber;

static Class1()
{
_magicNumber = 4;
}
}
So the next thing to try was to test this out in VB.NET:

Module Module1

Sub New()
Debug.WriteLine("New")
End Sub

Public Sub Test()
Debug.WriteLine("Test")
End Sub

Public Sub Test2()
Debug.WriteLine("Test2")
End Sub
End Module
Running this and calling the methods Test / Test2 (in that order) yields this:

New
Test
Test2

So as you might expect, the construct only gets called once, but is called before any members are accessed in the module. Handy!

Sunday, May 10, 2009

OPC at RVNUG: The code and the slides


First things first: Here is the code and here are the slides.

Thanks to everyone who attended (and participated in) my resent presentation on the Open Packaging Convention (OPC) at the Roanoke Valley .NET User Group (RVNUG). It was a rowdy group (my favorite kind) and it was a blast.

Besides coming up with various connotations for the words 'Package', 'Parts' and 'Stream', we discussed some handy ways to use OPC:
  • Exporting / backing up data
  • Storing a gallery of images with additional metadata (geocoding, timestamp information,etc)
  • Grouping together log files. This application seemed to generate the most interest.
OPC is a dirt simple way to store data in one place without needing a database.