How to Check If a String Contains a Character in C#

C# string contains character: the string evan@reed shown as a character grid with the @ at index 4, Contains('@') returns True

Need to know if a name, email or code has a certain letter in it? In C#, text.Contains(‘M’) answers that in one call and returns true or false. In this tutorial, I’ll walk one customer name, Jenna Morales, through each C# string contains character check worth knowing on .NET 10: Output: ‘M’ is in “Jenna … Read more >>

How to Convert String to Int with Leading Zeros in C#

Convert string to int with leading zeros in C#: int.Parse turns "00042" into 42 and ToString("D5") formats it back as 00042

Parsing “00042” in C# gives you 42, every time. When you convert a string to int, leading zeros are dropped, because an int stores a value, not the digits you typed. In this tutorial, I’ll pin down how to convert string to int with leading zeros in C# on .NET 10: parse the number, then … Read more >>