2009-11-30 11 views

risposta

27
if (x.Contains(c)) 
{ 
//// Do Something 
} 

Utilizzando .NET 3.0/3.5; avrete bisogno di una gentilezza using System.Linq;

,

Dan

+0

Non funziona con 'byte's, la risposta con' Array.IndexOf' ↓ funziona. –

14

È possibile utilizzare Array.IndexOf metodo:

if (Array.IndexOf(x, c) > -1) 
{ 
    // The x array contains the character c 
} 
9

Se ho capito bene, è necessario verificare se c è in x. Poi:

if(x.Contains(c)) { ... } 
1
string input = "A_123000544654654"; 
string pattern = "[0-9]+"; 
System.Text.RegularExpressions.Regex.IsMatch(input, pattern); 
Problemi correlati