if string contains number c#
"abc3def".Any(c => char.IsDigit(c));
// Or to make it shorter:
"abc3def".Any(char.IsDigit);
if string contains number c#
"abc3def".Any(c => char.IsDigit(c));
// Or to make it shorter:
"abc3def".Any(char.IsDigit);
c# how do you check if a string contains only digits
if (str.All(char.IsDigit)) {
Console.WriteLine("This string only contains numbers");
}
c# check if string contains value
string s1 = "The quick brown fox jumps over the lazy dog";
string s2 = "fox";
bool b = s1.Contains(s2);
Console.WriteLine("'{0}' is in the string '{1}': {2}",
s2, s1, b);
if (b) {
int index = s1.IndexOf(s2);
if (index >= 0)
Console.WriteLine("'{0} begins at character position {1}",
s2, index + 1);
}
// This example displays the following output:
// 'fox' is in the string 'The quick brown fox jumps over the lazy dog': True
// 'fox begins at character position 17
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us