Jump to content

case sensitivity issue in C#

Go to solution Solved by DXMember,


if (keyInfo.KeyChar == 'Y' || keyInfro.KeyChar == 'y')

 

or

 


if(keyInfo.KeyChar.ToLower() == 'y')

I need to make y=Y for this, telll me if you have a better way.

 

if (keyinfo.KeyChar == 'Y')

 

 

Tell me if you need more source code than this

Motivation is where, and what you make of it.

 

“It is relatively unusual that a physical scientist is truly an atheist. Why is this true? Some point to the anthropic constraints, the remarkable fine tuning of the universe. For example, Freeman Dyson, a Princeton faculty member, has said, ‘Nature has been kinder to us that we had any right to expect.'”  Albert Einstein

Link to comment
https://linustechtips.com/topic/622414-case-sensitivity-issue-in-c/
Share on other sites

Link to post
Share on other sites


if (keyInfo.KeyChar == 'Y' || keyInfro.KeyChar == 'y')

 

or

 


if(keyInfo.KeyChar.ToLower() == 'y')

CPU: Intel i7 5820K @ 4.20 GHz | MotherboardMSI X99S SLI PLUS | RAM: Corsair LPX 16GB DDR4 @ 2666MHz | GPU: Sapphire R9 Fury (x2 CrossFire)
Storage: Samsung 950Pro 512GB // OCZ Vector150 240GB // Seagate 1TB | PSU: Seasonic 1050 Snow Silent | Case: NZXT H440 | Cooling: Nepton 240M
FireStrike // Extreme // Ultra // 8K // 16K

 

Link to post
Share on other sites

Just now, DXMember said:

if(keyInfo.KeyChar.ToLower() == 'y')

 

This. This is Microsoft's standard guideline for comparing strings when case cannot be known.

Alternatively if you capture the key and put it in a string:

if (myString.ToLower() == "y")

 

 

ENCRYPTION IS NOT A CRIME

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×