I have a class that contains a tuple
public List<Tuple<int, char>> TVRPositions { get; set; }
I have added to this tuple list by turning a string into a char array the int represents the position of the char while the char represents the actual value.
I have to now compare those values with a string that I have turned into a char array called TVRBitArray. I have gone ahead by using a forloop and a foreach. What I realized is that this takes a lot of time and I have to unfortunately loop through quite a bit.
Here is the code
for (int i = 0; i < TVRBitArray.Length; i++) { foreach (var tuple in CardRule.TVRPositions) { if (tuple.Item1 == i && tuple.Item2 == TVRBitArray[i]) { if (listenerSettings.DebugOn) { logToFile.WriteLog("TVRMATCH = TRUE"); } TVRMatch = true; } else { if (listenerSettings.DebugOn) { logToFile.WriteLog("TVRMATCH = False"); } TVRMatch = false; } } }
Is there a much more efficient way of matching my variables inside my tuple list to the second string to see if its a perfect match?
Thanks
https://stackoverflow.com/questions/65784783/how-to-match-a-string-with-tuples January 19, 2021 at 10:37AM
没有评论:
发表评论