18.11.08

C# Cheat Sheet Cache

As described here, this is a cache/cheat sheet of commonly forgotten (and thus Googled) details for the C# language.

Category Item Sample Notes
Anonymous Delegate/Method Inline Syntax

delegate(int i) { return 0.0; }

Creates a delegate that takes an int and returns a double.
Anonymous Delegate/Method Sort List<T>

List<int> lst = new List<int>();

lst.Sort(

delegate(int i1, int i2)

{

    return i1.CompareTo(i2);

});

Sorts a templated list using an inline function that shares the local scope.

Programming Language Cheat Sheet Caching

After perusing a question on stackoverflow.com, I realized that it would, indeed, be useful to have a quick reference of various languages. As a developer that is constantly switching language contexts, there is definitely an overhead associated with doing so. Work in C++ long enough, for example, and your knowledge of C# generics blurs towards the template side, and vice versa.

A fair amount of programming is consistent across multiple languages. However, there are items that particularly are difficult to remember or re-learn. Rather than having quick references that attempt to cover everything, I have made the realization that it is better to just have quick entries for imformation that you always end up Googling anyway. It’s not like C#’s anonymous delegate syntax changes, I just have a hard time remembering the specifics and syntactic sugaring.

In programming, the repeated re-derivation of a result is inefficient. Dynamic Programming encourages one to cache commonly used results to improve efficiency. And so I present the devfuel.com Quick Reference Caches (A work in progress that will be updated as I use the listed language):

  • C Cheat Sheet Cache
  • C++ Cheat Sheet Cache
  • C# Cheat Sheet Cache
  • VB Cheat Sheet Cache
  • VB.NET Cheat Sheet Cache
  • Python Cheat Sheet Cache
  • etc.

13.11.08

.NET Custom Install Class and InstallUtil.exe Parameters: Order Matters

I have been working with custom install classes on .NET assemblies. Conveniently, they can be used to perform all manner of tasks through the use of the .net tool Installutil. When testing the ability to pass custom parameters (via the installutil.exe command line) I ran into a quirk:

It appears that parameters were being ignored if I passed them from an MSDOS console or batch file.

I knew this had to be a fluke, and finally stumbled on the answer: Order matters…or at least, put the assembly name last?

“c:\Windows\Microsoft.NET\Framework\v2.0.50727\installutil.exe Assembly.dll /Key=Value” will not work.
but…
“c:\Windows\Microsoft.NET\Framework\v2.0.50727\installutil.exe /Key=Value Assembly.dll” will ;)

4.11.08

Lose your find? (VS2008 Find Dialog)

Today I lost my find! I had a macro running while my "Find in Files" was running. It crashed and my Visual Studio 2008 Find dialog no longer would come up...I felt helpless and defenseless. But... you too can have your find back by going to:
Microsoft Visual Studio 2008->Visual Studio Tools->Visual Studio 2008 Command Prompt type: devenv /resetsettings
Thanx Samir!