13 Nov 2011

C# Working With string part 2

Consider this example, which uses Replace, Insert, and ToUpper:

public class TestStringsApp
    public static void Main(string[] args) 
    { 
         string a = "strong"; // Replace all 'o' with 'i' 
         string b = a.Replace('o', 'i'); 
         Console.WriteLine(b);
         string c = b.Insert(3, "engthen"); string d = c.ToUpper(); 
         Console.WriteLine(d); 
    }
}

The output from this application will be:

string STRENGTHENING

No comments:

Post a Comment