Whether it is a brisk walk, a game of golf, killing aliens, or a good book, everyone needs a little down time to recharge. And several times a year, it is good to extend that downtime and let the mind relax and run free. I am lucky enough to have a sister with a lake […]
Coalesce and Ternary Operators
Coalesce Operator The coalesce operator, also called the null coalescing operator, is new in VB 9 and C# 2.0. It helps you work with nulls (Nothing in VB). The coalesce operator involves two expressions. The first expression must evaluate to a nullable type or reference type. The first expression is the result if the first […]
Inferred Typing
If you are using Visual Studio 2008 (.NET Framework 3.5) or newer, you can leverage inferred typing. Inferred typing allows the compiler to infer your data types instead of you having to explicitly define the type. Variables that use inferred typing are still strongly typed, they just depend on .NET for determining (or inferring) the […]
Caller Id: Using StackTrace
There are situations where you may want to know who called a particular method in your application. Maybe you want to log it or use the information for debugging purposes. Whatever the reason, you can get information on the call stack using the StackTrace class. A stack trace is basically information on the active stack […]
Finding Controls on Forms
There are often times that you need to find specific controls on a Windows Form (WinForm). For example, you may want to find all of the TextBoxes to clear their contents, set their background color, or hook up events. You may want to find all of the checkboxes to check or uncheck them. Or find […]
Doctor Who
I remember watching Doctor Who in college when Tom Baker was the doctor. Those were the days before VCR recording and TiVo, so we had to rush home to ensure we caught that next episode. Tom Baker’s Doctor Who was smart, logical, and a little crazy. And always with the striped double-length scarf. […]
Linq: Sorting a DataTable
Last night, my husband (who is also a .NET developer) asked me about sorting a DataTable by user-defined columns. (Yes, we are a pretty exciting couple!) Most developers that work with DataTables know how to sort the DataTable using a DataView.Sort. If you are interested in that technique, you can view the msdn documentation here. […]
Writing Data from a DataTable to Excel
As with most things in Visual Studio, there are many ways to export data from your .NET application to an Excel spreadsheet. This post covers one straightforward technique. First, set a reference to the desired version of the Microsoft Excel Object Library from the COM tab of the Add Reference dialog. The resulting reference appears […]
User Control Events in VB and C#
There are many things in VB.NET and C# that are very similar. So if you know that basic syntax of both languages, it is relatively easy to convert a few lines of code from one to the other. Not so much with events. This is one area where it is easy to get tripped up […]
VB or C#?
I learned to program using structured programming techniques with RSTS/E BASIC on a PDP 11/45 and progressed to VAX BASIC on a VAX 11/70. This was before database products were common, so we created our own data structures using hash tables and linked lists. Then came Ingres, and we moved to a relational database system. […]