Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Strings
- Sub Main()
- Dim s1 As String = "Pippo"
- Dim s2 As New String("Pippo")
- Dim c() As Char = {"P", "i", "p", "p", "o"}
- Dim s3 As New String(c)
- Console.WriteLine("s1 = {0}", s1)
- Console.WriteLine("s2 = {0}", s2)
- Console.WriteLine("s3 = {0}", s3)
- Console.WriteLine("s1 == s2 ? {0} - s1 == s3 ? {1}", s1 = s2, s1 = s3)
- Console.WriteLine(s1.PadLeft(15))
- Console.WriteLine(s1.PadRight(15, "*"))
- Console.WriteLine("Length: {0}", s1.Length)
- Console.WriteLine("s1(3) = {0}", s1(3))
- Console.WriteLine("index of 'ip': {0}", s1.IndexOf("ip"))
- Console.WriteLine("substring from 1 count 2: {0}", s1.Substring(1, 2))
- Dim s4 As String = " Pippo "
- Console.WriteLine("|{0}|", s4)
- Console.WriteLine("|{0}|", s4.TrimStart())
- Console.WriteLine("|{0}|", s4.TrimEnd())
- Console.WriteLine("|{0}|", s4.Trim())
- Console.WriteLine("lowercase: {0}", s1.ToLower)
- Console.WriteLine("uppercase: {0}", s1.ToUpper)
- ' parametro: caratteri per i quali è ottimizzato default(16)
- Dim sb As New Text.StringBuilder(20)
- sb.Append("Questa è una prova.")
- sb.AppendFormat("Sono le ore {0}", DateTime.Now)
- sb.AppendLine()
- sb.AppendLine("Ritorno a capo")
- Console.WriteLine(sb.ToString)
- sb.Remove(2, 3)
- Console.WriteLine(sb.ToString)
- sb.Replace("una prova", "un esempio")
- Console.WriteLine(sb.ToString)
- Dim s As String = String.Format("{1} {0:d} {2:c} {0:dd}/{0:MMM}/{0:yy}",
- DateTime.Now,
- "Esempio: ",
- 123.65)
- Console.WriteLine(s)
- Console.ReadLine()
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement