Wrong question, no need to answer it the way you expect. Not only such search of the index would compromise performance, but it's also absolutely not needed.
Your mistake is having the field
String _value;
you never need it. Besides, related problem is: it's bad to have the field
Values
as the instance field; it should really be static read-only field. Indeed, you don't want to carry this array object with all of your instances, because it is the object to be shared by all your instances.
To fix the design of you class, declare value as byte. First of all, this type, as an integer type, is convenient for all calculations. Second of all, it will save you from the pointless search. Your only problem is finding the string value of the card (let me call it "Name", or you could have "Name" and "ShortName", and this is a simple as the index in the array
Values
. So, it should be something like that:
class Card {
public string Name { get { return names[cardValue]; } }
static readonly string[] names = new string[] {
"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", };
byte cardValue;
}
And I believe you will never need a constructor which accepts name (short or full) of the card, you will just need its numeric value. Those strings values are only needed to show the game on screen, so the are needed only on output of your calculation.
I must note that you show a very common but sorrowful fallacy of many beginners these days: attempt to work with strings representing data instead of actual data. I would advise you to get rid of this habit. :-)
—SA