I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..
using System;
public class StringExercise
{
public static void Main()
{
string str1;
int i, length;
Console.Write("Enter the string : ");
str1 = Console.ReadLine();
length = str1.Length;
string[] str2 = new string[length];
/* Copies string1 to string2 character by character */
i = 0;
while (i < length)
{
string tmp = str1[i].ToString();
str2[i] = tmp;
i++;
}
Console.Write("\nThe First string is : {0}\n", str1);
Console.Write("The Second string is : {0}\n", string.Join("", str2));
Console.Write("Number of characters copied : {0}\n\n", i);
Console.ReadLine();
}
}
I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..
Result:
Enter the string : tech study
The First string is : tech study
The Second string is : tech study
Number of characters copied : 10
need an explanation for this answer? contact us directly to get an explanation for this answer