QA: Using Enum.Parse to Convert a String to an Enumeration Value

Published on Author Rob Windsor1 Comment

Question:I have a string that holds the name of a value from an enumeration. How do I “cast“ that to the actual enumeration type? Answer:You can use the Parse method of the Enum class to do this conversion for you. Some sample VB code is shown below. Dim dr As DialogResultdr = CType([Enum].Parse(GetType(DialogResult), “Cancel”), DialogResult)MsgBox(dr.ToString)

Garbage Collection, Finalizers and Dispose

Published on Author Rob WindsorLeave a comment

I’m concerned with the number of developers I meet who really don’t understand the garbage collection mechanism in .NET. I think this is an extremely important topic because not knowing how object lifetimes are managed will have a negative effect on every .NET application you write! Are you familiar with the Dispose method? Did you… Continue reading Garbage Collection, Finalizers and Dispose