using System;
class MainClass {
public static void Main() {
string[] myStrings = {"To", "be", "or", "not","to", "be"};
string myString = String.Join(".", myStrings);
Console.WriteLine("myString = " + myString);
if (myString.StartsWith("To")) {
Console.WriteLine("myString starts with "To"");
}
if (myString.EndsWith("be")) {
Console.WriteLine("myString ends with "be"");
}
}
}
use the Join() method to join strings
using System;
class MainClass {
public static void Main() {
string[] myStrings = {"To", "be", "or", "not","to", "be"};
string myString9 = String.Join(".", myStrings);
Console.WriteLine("myString9 = " + myString9);
}
}
use the Copy() method to copy a string
using System;
class MainClass {
public static void Main() {
string myString4 = String.Concat("Friends, ", "Romans");
Console.WriteLine("myString4 = " + myString4);
Console.WriteLine("Copying myString4 to myString7 using Copy()");
string myString7 = String.Copy(myString4);
Console.WriteLine("myString7 = " + myString7);
}
}
use the addition operator (+) to concatenate strings
using System;
class MainClass {
public static void Main() {
string myString6 = "To be, " + "or not to be";
Console.WriteLine(""To be, " + "or not to be" = " + myString6);
}
}
use the Concat() method to concatenate strings
create some strings
using System;
class MainClass {
public static void Main() {
string myString = "To be or not to be";
string myString2 = "... that is the question";
string myString3 = @" Friends, Romans, countrymen,
lend me your ears";
// display the strings and their Length properties
Console.WriteLine("myString = " + myString);
Console.WriteLine("myString.Length = "
+ myString.Length);
Console.WriteLine("myString2 = " + myString2);
Console.WriteLine
("myString2.Length = " + myString2.Length);
Console.WriteLine("myString3 = " + myString3);
Console.WriteLine
("myString3.Length = " + myString3.Length);
}
}
Is Palindrome
using System;
using System.Text;
public class MainClass {
public static bool IsPalindrome(string s) {
int iLength, iHalfLen;
iLength = s.Length – 1;
iHalfLen = iLength / 2;
for (int i = 0; i <= iHalfLen; i++) {
if (s.Substring(i, 1) !=
s.Substring(iLength - i, 1)) {
return false;
}
}
return true;
}
static void Main(string[] args) {
string[] sa = new string[]{"level", "minim", "radar"};
foreach (string v in sa)
Console.WriteLine("{0} {1}",v, IsPalindrome(v));
}
}
[/csharp]

