Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Answer Posted / krishana singh gniit

using System;
using System.Text;

class Program
{
static void Main()
{
//
// Create an array with five strings.
//
string[] array = new string[5];
array[0] = "Dot";
array[1] = "Net";
array[2] = "Perls";
array[3] = "Sam";
array[4] = "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();
}

static string ConvertStringArrayToStringJoin(string[]
array)
{
//
// Use string Join to concatenate the string
elements.
//
string result = string.Join(".", array);
return result;
}
}

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is application object in c#?

869


What is c# best for?

864


What does the keyword “virtual” declare for a method or property?

905


What is the syntax for calling an overloaded constructor within a constructor?

907


Is string passed by reference in c#?

867


Can namespace contain the private class?

889


How do you prevent a class from being inherited in c#?

784


How to get the sum of last 3 items in a list using lambda expressions?

890


What is dataset and dataadapter in c#?

875


Is c++ or c# better?

889


Where do we set the min and max pool size for connection pooling?

907


Explain the concepts of cts and cls(common language specification).

917


If you want to convert a base type to a derived type, what type of conversion do you use?

884


How long will it take to learn c#?

917


Is Multiple-inheritance supported by c#?

934