Created
December 28, 2019 14:50
-
-
Save AnujJha-stack/efb85b793f2038523f75a07ea991c41b to your computer and use it in GitHub Desktop.
C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----------------------------------------------------------------------------------------------------------------------- | |
####################################################################################################################### | |
----------------------------------------------------------------------------------------------------------------------- | |
string firstFriend = "Maria"; | |
string secondFriend = "Sage"; | |
Console.WriteLine($"My friends are {firstFriend} and {secondFriend}"); | |
>>My friends are Maria and Sage. | |
----------------------------------------------------------------------------------------------------------------------- | |
####################################################################################################################### | |
----------------------------------------------------------------------------------------------------------------------- | |
#TRIM METHOD : remove white spaces before and after the string. | |
syntax: | |
StringVariable.Trim() // remove from both side | |
StringVariable.TrimStart() // remove from start | |
StringVariable.TrimEnd() // remove from end | |
----------------------------------------------------------------------------------------------------------------------- | |
string greeting = " Hello World! "; | |
Console.WriteLine($"[{greeting}]"); | |
string trimmedGreeting = greeting.TrimStart(); | |
Console.WriteLine($"[{trimmedGreeting}]"); | |
trimmedGreeting = greeting.TrimEnd(); | |
Console.WriteLine($"[{trimmedGreeting}]"); | |
trimmedGreeting = greeting.Trim(); | |
Console.WriteLine($"[{trimmedGreeting}]"); | |
>>[ Hello World! ] | |
>>[Hello World! ] | |
>>[ Hello World!] | |
----------------------------------------------------------------------------------------------------------------------- | |
####################################################################################################################### | |
----------------------------------------------------------------------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment