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?

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / mohammed ameem

string [] strings = new string[]{"abcd","efgh","ijkl"}();
//create generic list of stringbuilder of length equal to
string array
List<System.Text.StringBuilder> stringBs = new
List<System.Text.StringBuilder>(strings.Length);
for(int i=0;i<strings.Length;i++)
{
stringBS[i] = new StringBuilder(s);//initialize
stringbuilder object
}
StringBuilder [] stringBuilders = stringBS.ToArray();

Is This Answer Correct ?    2 Yes 6 No

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

Answer / 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

More C Sharp Interview Questions

What are the steps to make an assembly to public?

0 Answers  


Which is more efficient for loop or while loop?

0 Answers  


HOw to judge a person for a team if you are allowed to ask only 2 questions to him?

2 Answers   TCS,


What?s the difference between an interface and abstract class?

2 Answers   Patni,


What's the difference between an integer and int?

0 Answers  


When should I throw an exception?

0 Answers  


What is difference between float and integer?

0 Answers  


explain synchronous and asynchronous in C#

3 Answers   AxSys, Mastek, Synechron,


What is the difference between method and constructor in c#?

0 Answers  


What is public or shared assemblies ?

0 Answers  


Is a structure a class?

0 Answers  


how to use msflexgrid in asp.net

1 Answers   nSoft, Unichem,


Categories