C# Code Converter

No Comments »

DeveloperFusion offers a free .NET code converter.  Simply paste your C# or VB.NET code into this web-based tool, then select your target language: C#, VB.NET, Python or Ruby.  Supports syntax up to .NET 3.5.

Code Converter

Add Drop Shadow to Borderless Form

8 Comments »

When you create a Form with a border, Windows automatically draws a drop shadow around the form, as shown here:

Border form with shadow

However, if you set the form’s FormBorderStyle property to None, Windows draws neither the form border nor the drop shadow, as shown here:

Borderless form with no shadow

Read the rest of this entry »

C# Convert Byte Array to String

2 Comments »

It’s easy to convert a byte array to a string.  For an ASCII string, use the Encoding.ASCII.GetString static method:

byte[] buffer = new byte[10];
// todo: populate the buffer with string data
string s = Encoding.ASCII.GetString( buffer );

Convert String to Byte Array

1 Comment »

It’s easy to convert a string to a byte array.  For an ASCII string, use the Encoding.ASCII.GetBytes static method:

string s = "Test String";
byte[] byteArray = Encoding.ASCII.GetBytes( s );

Read File into Byte Array

1 Comment »

It’s easy to read a file into a byte array.  Just use the File.ReadAllBytes static method.  This opens a binary file in read-only mode, reads the contents of the file into a byte array, and then closes the file.

string filePath = @"C:test.doc";
byte[] byteArray = File.ReadAllBytes( filePath );

Visual Studio 2010 and .NET Framework 4.0 Released Today

No Comments »

Microsoft is releasing Visual Studio 2010, .NET Framework 4.0, and Silverlight 4 at the Visual Studio Developer Conference in Las Vegas.  VS 2010 and .NET 4 are available today, and Silverlight 4 will be available to download later this week.

Read more at DevTopics >>

Microsoft Community Promise for C# and CLI

No Comments »

Microsoft is applying its Community Promise to the C# programming language and Common Language Infrastructure (CLI).  This means that anyone can freely build, sell, distribute or use programs with C# and the CLI without signing a license agreement or otherwise communicating to Microsoft.  This applies to all distribution models including open source and GPL.  Under the Community Promise, Microsoft will not assert its Necessary Claims.

In other words, build all you want with C# and .NET, Microsoft won’t sue you for copyright or patent infringement.

Specifically, this announcement applies to the ECMA 334 (C#) and ECMA 335 (CLI) specifications.

“The Community Promise is an excellent vehicle and, in this situation, ensures the best balance of interoperability and flexibility for developers,” said Scott Guthrie, Corporate Vice President for the .NET Developer Platform.

C# Decimal: Literals, Conversions and Formatting

3 Comments »

The C# decimal keyword denotes a 128-bit data type.  Compared to floating-point types, the decimal type has a greater precision and a smaller range, which makes it suitable for financial and monetary calculations.

Approximate Range: ±1.0 × 10−28 to ±7.9 × 1028

Precision:  28-29 significant digits

.NET Type:  System.Decimal

Read the rest of this entry »

The Proper Way to Show the Wait Cursor

22 Comments »

It’s common UI courtesy to show the Wait cursor when performing a long operation that requires the user to wait.  Here is how the Wait cursor appears in Windows Vista:

Wait cursor

But developers often go about this the wrong way by setting the Cursor.Current property as follows:

Cursor.Current = Cursors.WaitCursor;

Read the rest of this entry »

Clean/Strip/Remove Binary Characters from C# String

4 Comments »

Sometimes you may need to display or print an input string that contains binary characters.  The following function replaces all binary characters in a string with a blank.  You can easily modify this method to remove other undesirable characters (such as high-ASCII) if needed.

Read the rest of this entry »

« go backkeep looking »