March 2004
Intermediate to advanced
560 pages
26h 47m
English
using System;
namespace Samples
{
public class StringSample
{
public static void Main()
{
string s = "Hello World!";
Console.WriteLine("\"{0}\".Length: {1}",
s, s.Length);
Console.WriteLine("\"{0}\".ToUpper(): {1}",
s, s.ToUpper());
Console.WriteLine("\"{0}\".ToLower(): {1}",
s, s.ToLower());
char c = 'l';
Console.WriteLine("\"{0}\".IndexOf({1}): {2}",
s, c, s.IndexOf(c));
int i = 5;
Console.WriteLine("\"{0}\".IndexOf({1}, {2}): {3}",
s, c, i, s.IndexOf(c,i));
Console.WriteLine("\"{0}\".LastIndexOf({1}): {2}",
s, c, s.LastIndexOf(c));
}
}
}
"Hello World!".Length: 12 "Hello World!".ToUpper(): HELLO WORLD! "Hello World!".ToLower(): hello world! "Hello World!".IndexOf(l): 2 "Hello World!".IndexOf(l, 5): 9 "Hello ...
Read now
Unlock full access