C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
And: The uppercase character in the string was changed to a lowercase one—but only in the copied, returned string.
Tip: The original string (value) is left alone after strings.ToLower returns. This is a behavior shared by many modern languages.
Golang program that uses ToLower
package main
import (
"fmt"
"strings"
)
func main() {
value := "Name"
// convertolowercase
valueLower := strings.ToLower(value)
fmt.Println("BEFORE:", value)
fmt.Println("AFTER: ", valueLower)
}
Output
BEFORE: Name
AFTER: name
Golang program that uses ToUpper
package main
import (
"fmt"
"strings"
)
func main() {
value := "The Dev Codes"
// Use ToUpper.
valueUpper := strings.ToUpper(value)
fmt.Println("BEFORE:", value)
fmt.Println("AFTER: ", valueUpper)
}
Output
BEFORE: The Dev Codes
AFTER: DOT NET PERLS
Golang program that uses Title func
package main
import (
"fmt"
"strings"
)
func main() {
name := "the apology"
// Capitalize this string.
result := strings.Title(name)
fmt.Println(result)
}
Output
The Apology