vista keeps shadow copies of files and folders when it creates its daily restore points. so if you delete something accidentally, right-click on the folder and go to the “Previous Versions” tab; you can browse through the contents of the folder as it existed at the last restore point. there’s no fancy gui and you only get the last 2 restore points, but it got the job done--
Thursday, February 7, 2008
vista shadow copies just saved me
Monday, February 4, 2008
chaining the C# ?? Operator
string value1 = null;
string value2 = "Test1";
string result = value1 != null ? value1 : value2;
which causes result containing Test1 or the second value.
In C# you can shortcut this special null comparison case with the new ??:
string result = value1 ?? value2;
Friday, January 25, 2008
debug .net library code
msft released the code to a whole bunch of .net libraries last week, Shawn Burke details the steps to take to see it:
Thursday, January 3, 2008
CTO interview on Microsoft's Startup Superstars
Friday, December 21, 2007
helpful sql perf queries
http://msdn.microsoft.com/msdnmag/issues/08/01/SqlDmvs/default.aspx
Thursday, November 1, 2007
sourcevault DOES do unicode diffs
Friday, June 22, 2007
avoid finalizers/use "using"
this is something we’ve gotten wrong a bit in places: in c#, only use a finalizer (i.e. a ~ClassName() method) if you need to clean-up unmanaged resources you’ve allocated. the reason for this is that if your class has a finalizer, the garbage collector will place it in the finalization queue and will not release it immediately. if you do have unmanaged resources and require a finalizer, implement IDisposable and do your cleanup in a shared Dispose(bool isDisposing) method. make sure to call GC.SuppressFinalize() in your Dispose() method so that if your client has already called Dispose(), your object is not placed in the finalization queue. for example:
public class ClassName : IDisposable
{
private bool m_IsDisposed;
~ClassName()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
public void Dispose(bool FromDisposeMethod)
{
if (!m_IsDisposed)
{
m_IsDisposed = true;
if (FromDisposeMethod)
{
//release managed resources; only do this if from Dispose method since they themselves might have been finalized
//...
}
//release unmanaged resources
//...
}
}
}
also, use "using" as much as possible. you can do this with any object that implements IDisposable:
using (MemoryStream ms = new MemoryStream())
{
//do whatever you want with ms
//...
}
using will automatically call Dispose() when the scope of this block ends, so you get very readable code and know that resources are properly released--
