I have the following:
if (model.PartitionKey.Substring(2, 2) == "05" ||
model.PartitionKey.Substring(2, 2) == "06")
I have more like this. Is there a more clean way to code this where I don’t have to repeat model.PartitionKey twice ?
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.
What about this:
That leaves you at liberty to keep the strings you are looking for in a nice list…
This will help a lot if the list of strings you are looking for gets longer than just two… Also, you can then add this to a set (
HashSet<string>) for more efficient lookup – but test this first, as overhead can eat up gains.