Feeds:
Posts
Comments

Archive for August, 2010

using System;
using System.IO;
using System.Text;

namespace Application1
{
    class Program
    {
        static void Main( string[] args )
        {
            string test = "Testing 1-2-3";

            // convert string to stream
            byte[] byteArray = Encoding.ASCII.GetBytes( test );
            MemoryStream stream = new MemoryStream( byteArray );

            // convert stream to string
            StreamReader reader = new StreamReader( stream );
            string text = reader.ReadToEnd();

            Console.WriteLine( text );
            Console.ReadLine();
        }
    }
}

Source : http://www.csharp411.com/c-convert-string-to-stream-and-stream-to-string

Advertisements

Read Full Post »


AppDomain.CurrentDomain.BaseDirectory

Source : http://stackoverflow.com/questions/837488/how-can-i-get-the-applications-path-in-c-in-a-console-app

Read Full Post »

using System;
using System.Collections;
using System.Text;

public class MyClass
{
public static void Main()
{
byte[] text = Encoding.UTF8.GetBytes("my string");
string s = Encoding.Unicode.GetString(text);
Console.WriteLine(s);
s = Encoding.UTF8.GetString(text);
Console.WriteLine(s);
}
}

Read Full Post »

%d bloggers like this: