Case Conversion
ToUpper and ToLower
Converts a string to uppercase or lowercase.
string upper = sentence.ToUpper(); // "THE QUICK BROWN FOX"
string lower = sentence.ToLower(); // "the quick brown fox"
Trimming
Trim, TrimStart, and TrimEnd
Removes white-space characters from the beginning and end of a string.
string padded = " hello ";
string trimmed = padded.Trim(); // "hello"
string trimmedStart = padded.TrimStart(); // "hello "
string trimmedEnd = padded.TrimEnd(); // " hello"
Splitting
Split
Splits a string into an array of substrings based on a delimiter.
string[] words = sentence.Split(' '); // { "The", "quick", "brown", "fox" }
Comparing
Equals
Determines if two strings have the same value.
bool areEqual = string.Equals("Hello", "hello", StringComparison.OrdinalIgnoreCase); // true
Compare
Compares two strings and returns an integer that indicates their relative position in the sort order.
int comparisonResult = String.Compare("apple", "banana"); // -1 (apple < banana)
Case Conversion
ToUpper and ToLower
Converts a string to uppercase or lowercase.
string upper = sentence.ToUpper(); // "THE QUICK BROWN FOX" string lower = sentence.ToLower(); // "the quick brown fox"
Trimming
Trim, TrimStart, and TrimEnd
Removes white-space characters from the beginning and end of a string.
string padded = " hello "; string trimmed = padded.Trim(); // "hello" string trimmedStart = padded.TrimStart(); // "hello " string trimmedEnd = padded.TrimEnd(); // " hello"
Splitting
Split
Splits a string into an array of substrings based on a delimiter.
string[] words = sentence.Split(' '); // { "The", "quick", "brown", "fox" }
Comparing
Equals
Determines if two strings have the same value.
bool areEqual = string.Equals("Hello", "hello", StringComparison.OrdinalIgnoreCase); // true
Compare
Compares two strings and returns an integer that indicates their relative position in the sort order.
int comparisonResult = String.Compare("apple", "banana"); // -1 (apple < banana)
C# is primarily used on the Windows . NET framework, although it can be applied to an open source platform. This highly versatile programming language is an object-oriented programming language (OOP) and comparably new to the game, yet a reliable crowd pleaser.
The C# language is also easy to learn because by learning a small subset of the language you can immediately start to write useful code. More advanced features can be learnt as you become more proficient, but you are not forced to learn them to get up and running. C# is very good at encapsulating complexity.
The decision to opt for C# or Node. js largely hinges on the specific requirements of your project. If you're developing a CPU-intensive, enterprise-level application where stability and comprehensive tooling are crucial, C# might be your best bet.
C# is part of .NET, a free and open source development platform for building apps that run on Windows, macOS, Linux, iOS, and Android. There's an active community answering questions, producing samples, writing tutorials, authoring books, and more.
Copyrights © 2024 letsupdateskills All rights reserved