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 the default boolean value in c#?
What is the extension of c# file?
What is cookies c#?
What is out in c#?
If I have more than one version of one assemblies, then how'll I use old version (how/where to specify version number?)in my application?
What is dynamic dispatch?
What method is used to sort the elements of the array in descending order?
how to print invert pyramid in c#
Define delegate?
Name the two classes are required for implementing a windows service?
What is the implicit name of the parameter that gets passed into the set method/property of a class?
How do you declare an interface in c#?
How to use delegates with events?
How do I do a case-insensitive string comparison?
Does c# support multilevel inheritance?