Instead of looping over my string I'd like to use LINQ. How to do the following?
// explode our word
List<char> rackBag = new List<char>();
rackBag.AddRange("MYWORD??".ToCharArray());
// How many wildcards?
int wildCardCount = rackBag.Count(x => x.Equals("?"));
wildCardCount should equal 2.
Lots of unneeded steps there. Try this:
int wildCardCount = "MYWORD??".Count(x => x == '?');
rackBag.Count(x => x == '?');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With