Visual C++ .NET/Development/StringBuilder
Содержание
Add string to StringBuilder
#include "stdafx.h"
using namespace System;
using namespace System::IO;
using namespace System::Text;
int main(array<System::String ^> ^args)
{
StringBuilder ^tmppath = gcnew StringBuilder();
tmppath->Append("c:\\");
tmppath->Append(" ");
String ^path = tmppath->ToString()->Trim();
return 0;
}
Append char array to StringBuilder
#include "stdafx.h"
using namespace System;
using namespace System::Text;
int main()
{
StringBuilder^ sb = gcnew StringBuilder("C", 30);
sb->Append(gcnew array<Char>{"+","+"});
sb->Append("/CLI.");
sb->Insert(0, "asdf ");
sb->Replace(".","!");
Console::WriteLine( sb->ToString() );
}
Append to StringBuilder
#include "stdafx.h"
using namespace System;
using namespace System::Text;
int main()
{
StringBuilder^ sb = gcnew StringBuilder("C", 30);
sb->Append(gcnew array<Char>{"+","+"});
sb->Append("/CLI.");
sb->Insert(0, "asdf ");
sb->Replace(".","!");
Console::WriteLine( sb->ToString() );
}
Convert StringBuilder to String
#include "stdafx.h"
using namespace System;
using namespace System::Text;
int main()
{
StringBuilder^ sb = gcnew StringBuilder("C", 30);
sb->Append(gcnew array<Char>{"+","+"});
sb->Append("/CLI.");
sb->Insert(0, "asdf ");
sb->Replace(".","!");
Console::WriteLine( sb->ToString() );
}
Insert String to StringBuilder
#include "stdafx.h"
using namespace System;
using namespace System::Text;
int main()
{
StringBuilder^ sb = gcnew StringBuilder("C", 30);
sb->Append(gcnew array<Char>{"+","+"});
sb->Append("/CLI.");
sb->Insert(0, "asdf ");
sb->Replace(".","!");
Console::WriteLine( sb->ToString() );
}
Replace String in StringBuilder
#include "stdafx.h"
using namespace System;
using namespace System::Text;
int main()
{
StringBuilder^ sb = gcnew StringBuilder("C", 30);
sb->Append(gcnew array<Char>{"+","+"});
sb->Append("/CLI.");
sb->Insert(0, "asdf ");
sb->Replace(".","!");
Console::WriteLine( sb->ToString() );
}