Position in a string C# -


i need know how check character in first position in string on c# code. example , if first character character "&" or other.

thanks.

as can see answers, there many ways accomplish this. should careful avoid exceptions thrown if attempt call methods on string null or use indexers on string null or empty.

if(!string.isnullorempty(input) && input[0] == '&') {     // yes } 

or…

if(input != null && input.startswith("&")) {     // yes } 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -