I need to return a maximum of 9 digits of the next line abc. How to do it?
public string test() { string abc="asdhfjsdfkjhfiovjalksdhafbvklxkjszjhd"; return abc; }
Use String.Substring:
String.Substring
public string test() { string abc="asdhfjsdfkjhfiovjalksdhafbvklxkjszjhd"; return abc.Substring(0, 9); }
public string test() { string abc="asdhfjsdfkjhfiovjalksdhafbvklxkjszjhd"; return abc.Substring(0,9); }
You can use Substringas others answered
Substring
Besides
public string test() { string abc = "asdhfjsdfkjhfiovjalksdhafbvklxkjszjhd"; abc = new string(abc.Take(9).ToArray()); }
http://www.dotnetperls.com/substring
you can use this:
public string test() { string abc="asdhfjsdfkjhfiovjalksdhafbvklxkjszjhd"; abc = abc.Substring(0, 9); return abc; }