C# Convert String to Stream, and Stream to String

27 Comments »

It’s fairly easy to convert a C# String to a Stream and vice-versa.

Read the rest of this entry »

Show ToolTip on TabPage in TabControl

3 Comments »

So you’ve set the ToolTipText property of a TabPage in a TabControl.  When the user moves the mouse pointer over the tab, the text you specified is supposed to show in a tooltip. 

TabPage ToolTip

But what if the tooltip is not showing?  Fortunately, this problem has an easy solution:

Set the ShowToolTips property in the TabControl to true.

Clear C# StringBuilder

8 Comments »

Many .NET developers are baffled by the lack of a “Clear” method in the StringBuilder class.  For example, if you are using a StringBuilder in a loop, you may want to clear its contents at the beginning of each loop.

Read the rest of this entry »

Determine Windows Version and Edition with C#

19 Comments »

This article explains how to use C# to determine the name, edition, service pack, version and bits of the host operating system.

For example, the results on my PC would be:

Operation System Information
—————————-
Name = Windows Vista
Edition = Home Premium
Service Pack = Service Pack 1
Version = 6.0.6001.65536
Bits = 64

Read the rest of this entry »

C# Focus TextBox on Form Load

3 Comments »

When showing a form that contains a TextBox, it’s common courtesy to focus the TextBox so that the user can begin typing immediately.

To focus a TextBox when a Windows Form first loads, simply set the TabIndex for the TextBox to zero (or the lowest TabIndex for any Control on the Form).

When a Form is displayed, it automatically focuses the Control with the lowest TabIndex.  Note that if your TextBox is pre-initialized with some text, then the entire Text will be selected, as shown below:

Entire text is selected

Read the rest of this entry »

C# Read Text File Line-by-Line

36 Comments »

Here is the code to read a text file from disk one line at a time into a string.  This code ensures the file exists and properly closes the file if an exception occurs.

Read the rest of this entry »

Best-Selling C# Books of 2008

2 Comments »

Following are the top-selling C# software development books of 2008 according to the Amazon.com sales rankings:

Read the rest of this entry »

Top 10 .NET News Stories of 2008

No Comments »

It’s that time of the year to reflect, analyze and compile our lives into a series of Top 10 lists.  As with every other Top 10 list, the items on this list and their order are highly subjective.  For example, some companies may not care about future versions of .NET — version 2.0 works just fine, thank you.  Other companies may need to develop a web application, so Silverlight 2.0 is their top story of the year.  So please comment below with your Top 10 List.

Following are the Top 10 stories in 2008 about software development with the Microsoft .NET Framework.

Read more at DevTopics

C# Overloaded Methods with Inherited Arguments

3 Comments »

This article discusses one of those programming topics that may be confusing at first but seems obvious once you know it.

As you know, C# enables you to overload the same method in a class with different arguments.  But it’s also possible to overload a method with arguments that inherit from one another.

Read the rest of this entry »

New .NET Logo

12 Comments »

New .NET Logo

The .NET development team at Microsoft has created a new .NET logo (shown above).  Their goal was to create a logo “that was in sync with the key values that we want .NET to stand for: consistency, robustness and great user experiences.  The result is a design we refer to as the ‘wave.’  The design is strong, simple and distinctive.  The suggestion of the letter ‘N’ in the design will become instantly recognizable over time as shorthand for the .NET brand name.”

« go backkeep looking »