string a="David ";Download Example Ex5
int b = 0;
a= string.Concat(a,4,5.6,b) ;
Console.WriteLine("a= {0}",a) ;
The output is a= David 45.60
The Contains and IndexOf Methods
This is a simple boolean check if one string is contained within another. Continuing with Ex5, this example uses the string a defined earlier.if (a.Contains("45.6"))In this case it does, so the above string is output but more often you want to know the exact index of where the string is contained. For this you use IndexOf() which has many overloads. Use it to return the position of a char in a string or even specify the type of search through the StringComparison numerations. These provide a comprehensive handling of Culture searching (both case sensitive and insensitive) which is the .NET name equivalent of locale. We'll come back to that in a later tutorial.
Console.WriteLine("{0} contains 45.6",a) ;
int pos = a.IndexOf(".6") ; Console.WriteLine("position of .6 is {0}", pos) ;This return 8, remember in C# the first char in a string is at position 0.
On the next page - More String Methods

