I hava a string like this:
var id = "01020304";
Is there a simple way I can split this into four variables called pr, pa, fo, it Each variable needs to have the two characters of the string. Looking for an elegant solution if it exists.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since you have four distinct variables, you can’t get much more elegant than using Substring:
Were you looking for an array of four 2-character substrings, you could get fancier:
EDIT: The same can be done with a LINQ expression: