A step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.
A C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.
This tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.
Converting from decimal to binary and back
This tutorial will show you how to convert from binary system (base 2) to decimal system (base 10) and back from decimal to binary. It provides a sample .NET 2.0 application which performs these conversions.
On Tuesday, August 9th 2005 at 09:30 AM
By Andrew Pociu (View Profile)
(Rated 4.2 with 34 votes)
Download this project
Download the application
You can download this project. It is developed in Visual Studio .NET 2005, using .NET Framework 2.0. However, the code can be used in .NET Framework 1.1 without any changes.
Here is how the application looks like in Windows Vista:
For more information on the binary numbering system read the Understanding Binary tutorial.
Converting from decimal to binary
Converting from decimal to binary involves a small algorithm that we need to use. There are multiple ways of converting an integer to binary, but I believe this one is the simplest to understand and implement:
Converting from binary to decimal
Conversion from binary to decimal is done even easier. We don't need to use an algorithm because the .NET Framework provides us with a method called Convert.ToInt64() to which you pass a decimal.
You can see in the Binary Convertor project how we use this method to convert the text inside the TextBox to binary (and then back to string so that we can show it in the second TextBox):
Notice that we passed two parameters to the ToInt64() method. One is the actual number (retrieved from the TextBox), and one is the number 2 which represents the base (base 2, being the binary system).
|Digg It! Del.icio.us Reddit StumbleIt Newsvine Furl BlinkList|
Rate this tutorial
There are no related tutorials.
Related Source Code
There is no related source code.
C# Job Search