Convert StringWriter to String : StringWriter « Development « Visual C++ .NET






Convert StringWriter to String

 

#include "stdafx.h"
#using "System.Windows.Forms.dll"

using namespace System;
using namespace System::IO;
using namespace System::Text;
using namespace System::Windows::Forms;

int main()
{
   StringWriter^ sw = gcnew StringWriter();
   sw->WriteLine("asdf");
   sw->Write("asdf\n");
   sw->WriteLine();

   String^ jambo = "asdf";
   String^ s = String::Format("{0}, {1}.", jambo, jambo);
   sw->WriteLine(s);
   sw->Write("Make a wish, {0}, {0}.", jambo);
   s = "asdf.\n";
   String::Concat(s, "asdf?");
   sw->WriteLine(s);


   StringBuilder^ sb = gcnew StringBuilder();
   sb->Append("asdf\n");
   sw->WriteLine(sb);

   // The resulting string might be displayed to the user in a GUI
   MessageBox::Show(sw->ToString(), "Poetry", MessageBoxButtons::OK);
}

   
  








Related examples in the same category

1.Using StringWriter to write string