For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Tuesday, November 11, 2014

Exact string comparison in C#

PROBLEM:
Exact string comparison in C# ,Case sensitive login in C#. Suppose you are storing login in database table as "Admin" and on the webpage or winform you are trying to compare it as "admin" then it is pass.But if you want to compare it as exact "Admin" the follow below steps:
Store "admin" in database table. So "admin" and "Admin" is not same

SOLUTION:
 String tmpLogin="Admin";
// Select user_login from user_info where user_login='Admin
String ret_login=Util.getLogin(tmpLogin);
// It will return "admin" so "admin" and "Admin" is not same. so it should false.
if (String.Equals(tmpLogin, ret_login, StringComparison.Ordinal)==false) {
                MessageBox.Show("Incorrect User Name.");
                label7.Text = "Incorrect UserName.";
                return;
} else {
     MessageBox.Show("Correct User Name.");
}




Share:

0 comments:

Post a Comment

Add Dependent Scripts

   here is the code that allow to add dependent script :         <script>         const addDependentScripts = async function( scriptsT...

Ads Inside Post

Powered by Blogger.

Arsip