Each time a new project is started, there is always a discussion (or there should be!) of what guidelines should be used in design, naming conventions, etc. I typically like to defer to the standards given by the company that creates the language, and then define any differences. For the case of C# and .NET [...]
Using LINQ in C# .Net 3.5, I have often had cases where I wanted to build my predicates dynamically based on the value of different runtime conditions or by iterating through a list, etc. You can easily append where clauses to an IQueryable<T> like so: query = query.Where(u => u.Name == “Scott”);query = query.Where(u => [...]
To get command line parameters in a standard console app (C#): static void Main(string[] args){ foreach (string arg in args) { … }} To get command line parameters in a windows forms app (C#): string[] args = Environment.GetCommandLineArgs();foreach (string arg in args){ …}
One of the big problems I faced in .Net 1.1 web applications was capturing the enter key so that the correct asp:button would be “clicked.” To solve this problem, ASP.Net 2.0 lets you specify this on the html form element with the defaultfocus and defaultbutton attributes. This is really slick and works like a charm. [...]
Most programming languages have built in libraries for generating random numbers from a uniform distribution. If you need to convert this to a normal or Gaussian distribution, some sort of transformation must be made. I found a good page that talks about this process and gives some example code in how to convert a uniform [...]
In a project I’m working on, and using LINQ, there have come a few times when I have needed to create my own SQL and send a query to the database. This has typically happened when I’m not doing queries that aren’t very straight forward, but I still want to accomplish the task with only [...]
Sometimes you have a library running outside of your traditional debug mode, but would like to call into it with a debugger. I specifically ran into this with a custom installer dll called by a custom action in my MSI. The following code will allow the process itself to request debugging. Then you can specify [...]
LINQ "gotchas"
I am using VS 2008 and LINQ (specifically LINQ to SQL) for a project at work right now. As I jump into this, I am going to document some of the pros, cons, and “gotchas” that I come across. Any articles in this series will have the label “LINQ” . Here is my first list [...]