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 jagged array in c#?
What is an iqueryable in c#?
What is xamarin used for?
What is the concept of strong names?
Define a partial class?
What do you know about Translate Accelerator?
Contrast System.String and System.Text.StringBuilder classes?
Can we instantiate abstract class in c#?
What is the difference between a function and a method?
What is the difference between properties and indexer in c#?
What do you mean by shared assembly?
Is c# 8 released?
What is the difference between out and ref in c#?
Which config file has all the supported channels/protocol?
Why is it important to override gethashcode when equals method is overridden?