20 April 2011

Convert String to Stream and stream to string


using System.IO;
using System.Text;
using System;
namespace CustomIoClasses
{
class ClsStream
{
public static string GetString(Stream ObjPriReader)
{
return new StreamReader(ObjPriReader).ReadToEnd();
}
public static Stream GetStream(String StrPriData)
{
byte[] byteArray = Encoding.ASCII.GetBytes(StrPriData);
MemoryStream stream = new MemoryStream(byteArray);
return stream;
}
static void Main(string[] args)
{
string str = "I love my India";
System.Console.WriteLine(GetString(GetStream(str)));
Console.ReadKey();

}
}
}

No comments:

Post a Comment

Your comments, Feedbacks and Suggestions are very much valuable to me :)

Things are upgraded

My Dear readers, I am really thankful for being supportive all these years. This site was the first blog site I ever created in my life...