how to convert String array to StringBuilder array or vice
versa?

Answer Posted / urukundappa.g

using System;
using System.Text;

class Program
{
static void Main()
{
// Create an array with five strings.
string[] array =
new string["Dot", "Net", "Perls", "Sam", "Allen"];

// Call the methods.
string result1 = ConvertStringArrayToString(array);
string result2 = ConvertStringArrayToStringJoin
(array);

// Display the results.
Console.WriteLine(result1);
Console.WriteLine(result2);
Console.Read();
}

static string ConvertStringArrayToString(string[] array)
{
// Concatenate all the elements into a
StringBuilder.
StringBuilder builder = new StringBuilder();
foreach (string value in array)
{
builder.Append(value);
builder.Append('.');
}
return builder.ToString();
}

StringBuilder [] stringBuilders = builder.ToArray();

Is This Answer Correct ?    0 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is application object in c#?

506


What is difference between throw and throws in c#?

454


Why singleton is sealed?

486


What is jit (just in time)?

555


Why are mutable structs evil?

541






What is cshtml extension?

520


Which types of inheritances does c# support?

463


How do I use the 'using' keyword with multiple objects?

511


What is the default value of date?

456


Is a dll an assembly?

476


What is c# used for?

515


What is c# console application?

483


What is oledb in c#?

505


What is desktop example?

489


Is stringbuilder faster than string concatenation c#?

447