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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Converting string value to System.IO.Stream

Converting string value to System.IO.Stream

Scheduled Pinned Locked Moved C#
helpcsharplearning
2 Posts 2 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.
  • N Offline
    N Offline
    Neel07
    wrote on last edited by
    #1

    Hi I want to convert one string input in one of my function in c# to System.IO.Stream object but it gives me conversion error in 2nd line of the below function static myFunc(string strInput) { Stream objStream; objStream=(Stream)strInput; } would much appreciate any help Thank you Share knowledge to enhance your learning

    S 1 Reply Last reply
    0
    • N Neel07

      Hi I want to convert one string input in one of my function in c# to System.IO.Stream object but it gives me conversion error in 2nd line of the below function static myFunc(string strInput) { Stream objStream; objStream=(Stream)strInput; } would much appreciate any help Thank you Share knowledge to enhance your learning

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      You can't expect to convert a type to something else just like that. If you can do with a Reader, you can try the StreamReader class. Or if you absolutely need a Stream, something like this will work

      string obj = "Senthil rocks";
      Stream s = new MemoryStream(Encoding.ASCII.GetBytes(obj));

      Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      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