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
What is parallel programming in c#?
How do I start a program in c#?
What is .cs file in c#?
How many types of constructors are available in c#?
What is the differences between datagrid, datalist and repeater in .net?
Can main method be final?
What is a string c#?
Is concurrent queue thread safe?
What is a base class in C#?
What are scriptable objects?
What is the difference between inheritance and abstract class?
Are c# strings null terminated?
Can the accessibility of a type member be greater than the accessibility of its containing type?
What's the difference between a static method and a non static method c#?
What are the namespace level elements?