There is a struct S with 2 string fields: A and B.
I want to convert an array of S into string array, containing all non-empty unique As and Bs. What is the most efficient way for that?
Regards,
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.
Above only works if the unique constraint is on the resulting collection – if you need a unique constraint on the set of A’s and B’s the following would work:
var myArray = new[] { As, Bs }.SelectMany(x => x).ToArray();