Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Write to a file in ASCII format

Write to a file in ASCII format

Scheduled Pinned Locked Moved C#
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AnnnS
    wrote on last edited by
    #1

    Hi i want to know how can we write some data in ASCII format . means if i write '49' its should not be in character format , instead the equalent character for ASCII 49 ie '1' has to be stored . Please its urgent . thanks in advance Akhil:confused:

    T G A 3 Replies Last reply
    0
    • A AnnnS

      Hi i want to know how can we write some data in ASCII format . means if i write '49' its should not be in character format , instead the equalent character for ASCII 49 ie '1' has to be stored . Please its urgent . thanks in advance Akhil:confused:

      T Offline
      T Offline
      Tehnoon
      wrote on last edited by
      #2

      If you use Convert.ToChar(48), it will return you '1', and so forth. :-D

      1 Reply Last reply
      0
      • A AnnnS

        Hi i want to know how can we write some data in ASCII format . means if i write '49' its should not be in character format , instead the equalent character for ASCII 49 ie '1' has to be stored . Please its urgent . thanks in advance Akhil:confused:

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        The Char data type in .NET is not ASCII but Unicode. You can easily convert between Char and Int32: int i = 49; char c = (char)i; char d = (char)49; You can also write characer codes inside a char or string literal: char e = '\x31'; char f = '\u0031'; --- b { font-weight: normal; }

        1 Reply Last reply
        0
        • A AnnnS

          Hi i want to know how can we write some data in ASCII format . means if i write '49' its should not be in character format , instead the equalent character for ASCII 49 ie '1' has to be stored . Please its urgent . thanks in advance Akhil:confused:

          A Offline
          A Offline
          Andrei Ungureanu
          wrote on last edited by
          #4

          Hi, There is a built in Encoder to ASCII and from ASCII. Just use System.Text.Encoding.ASCII.GetBytes and pass a string or a character array and it will provide you the ASCII byte array. The using System.Text.Encoding.ASCII.GetChars you can change back from ASCII to character. Hope it helps, Andrei

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups