Convert various data type to string with BitConverter : BitConverter « Development Class « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » Development Class » BitConverterScreenshots 
Convert various data type to string with BitConverter
 
using System;

class BitConverterDemo
{
    public static void Main()
    {
        double aDoubl = 0.1;
        float aSingl = 0.3F;
        long aLong = 2;
        int anInt = 4;
        short aShort = 5;
        char aChar = '*';
        bool aBool = true;

        Console.WriteLine(BitConverter.ToString(BitConverter.GetBytes(aDoubl)));
        Console.WriteLine(BitConverter.ToString(BitConverter.GetBytes(aSingl)));
        Console.WriteLine(BitConverter.ToString(BitConverter.GetBytes(aLong)));
        Console.WriteLine(BitConverter.ToString(BitConverter.GetBytes(anInt)));
        Console.WriteLine(BitConverter.ToString(BitConverter.GetBytes(aShort)));
        Console.WriteLine(BitConverter.ToString(BitConverter.GetBytes(aChar)));
        Console.WriteLine(BitConverter.ToString(BitConverter.GetBytes(aBool)));
    }
}

   
  
Related examples in the same category
1.Convert byte array to String with BitConverter
2.Convert byte array to Int32
3.BitConverter converts base data types to an array of bytes, and an array of bytes to base data types.
4.Convert bytes to UInt32.
5.Converts double number to a 64-bit signed integer.
6.Convert Boolean value to an array of bytes.
7.Convert Unicode character to an array of bytes.
8.Convert double to an array of bytes.
9.Convert 16-bit signed integer value to an array of bytes.
10.Convert 32-bit signed integer value to an array of bytes.
11.Convert 64-bit signed integer value to an array of bytes.
12.Convert single-precision floating point value to an array of bytes.
13.Convert specified 16-bit unsigned integer value to an array of bytes.
14.Convert specified 32-bit unsigned integer value to an array of bytes.
15.Convert specified 64-bit unsigned integer value to an array of bytes.
16.Converts 64-bit signed integer to a double-precision floating point number.
17.Indicates the byte order ("endianness")
18.Convert one byte at a specified position in a byte array to bool
19.Convert two bytes at a specified position in a byte array to a Unicode character
20.Convert two bytes at a specified position in a byte array to a 16-bit signed integer
21.Convert four bytes at a specified position in a byte array to a 32-bit signed integer
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.