The hex dump program : HEX « Language Basics « C# / C Sharp

C# / C Sharp
1. 2D Graphics
2. Collections Data Structure
3. Components
4. Database ADO.net
5. Development Class
6. Event
7. File Stream
8. GUI Windows Form
9. Language Basics
10. Network
11. Office
12. Regular Expressions
13. Services Event
14. Thread
15. Web Services
16. Windows
17. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
C# / C Sharp » Language Basics » HEXScreenshots 
The hex dump program
The hex dump program

using System;
using System.IO;

  class Class1 {
       public static string PadZerostring s, int len ) {
         string temp = s;
         for int i=s.Length; i<len; ++i ){
           temp = "0" + temp;
         
         return temp;
       }
       static void Main(string[] args) {
             StreamReader sr = new StreamReader"test.cs" );

             string line = "";
             int nCounter = 0;
             int nOffset = 0;
             while ( (line = sr.ReadLine()) != null ) {
                 for int i=0; i<line.Length; ++i ) {
                    int c = (int)line[i];
                    string fmt = String.Format("{0:x}", c);
            
                    if fmt.Length == )
                     fmt = PadZero(fmt, 2);
            
                    if nOffset % 16 == ) {
                     string offsetFmt = nOffset.ToString();
                     Console.Write(PadZero(offsetFmt,5)+": ");
                    }
            
                    Console.Write(fmt + " ");
                    if nCounter == 15 ) {
                      Console.Write("\n");
                      nCounter = 0;
                    else {
                     nCounter ++;
                    
                    nOffset ++;
                 }
             }
       }
  }


           
       
Related examples in the same category
ww___w___.___j___a_v__a2s_.__c_o_m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.