Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. If statement

If statement

Scheduled Pinned Locked Moved C#
question
8 Posts 5 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sottyoru
    wrote on last edited by
    #1

    Hello, I have couple of question about if statement. When I create password verifying program, at least 8 characters long is if (password.Length < 8) valid = false; like this, right? Then, how can I make program that must contain at least one digit and one uppercase for the password. Then, I tried to create while (valid && i < 1) { if (!Char.IsLetter(custID[i])) valid = false; i++; } like this, but it's not working. Please tell me.

    P D A 3 Replies Last reply
    0
    • S Sottyoru

      Hello, I have couple of question about if statement. When I create password verifying program, at least 8 characters long is if (password.Length < 8) valid = false; like this, right? Then, how can I make program that must contain at least one digit and one uppercase for the password. Then, I tried to create while (valid && i < 1) { if (!Char.IsLetter(custID[i])) valid = false; i++; } like this, but it's not working. Please tell me.

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      Look into String.IndexOfAny http://msdn.microsoft.com/en-us/library/11w09h50.aspx[^]

      1 Reply Last reply
      0
      • S Sottyoru

        Hello, I have couple of question about if statement. When I create password verifying program, at least 8 characters long is if (password.Length < 8) valid = false; like this, right? Then, how can I make program that must contain at least one digit and one uppercase for the password. Then, I tried to create while (valid && i < 1) { if (!Char.IsLetter(custID[i])) valid = false; i++; } like this, but it's not working. Please tell me.

        D Offline
        D Offline
        dusty_dex
        wrote on last edited by
        #3

        You should be able to figure something out from the following Password Strength Control Regular expressions can help but they're not a silver bullet.

        Q. Hey man! have you sorted out the finite soup machine? A. Why yes, it's celery or tomato.

        P 1 Reply Last reply
        0
        • D dusty_dex

          You should be able to figure something out from the following Password Strength Control Regular expressions can help but they're not a silver bullet.

          Q. Hey man! have you sorted out the finite soup machine? A. Why yes, it's celery or tomato.

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          You need to read his earlier post. It's homework.

          D 1 Reply Last reply
          0
          • S Sottyoru

            Hello, I have couple of question about if statement. When I create password verifying program, at least 8 characters long is if (password.Length < 8) valid = false; like this, right? Then, how can I make program that must contain at least one digit and one uppercase for the password. Then, I tried to create while (valid && i < 1) { if (!Char.IsLetter(custID[i])) valid = false; i++; } like this, but it's not working. Please tell me.

            A Offline
            A Offline
            ali_heidari_
            wrote on last edited by
            #5

            hi . if(password.Length < 8) is extreme 7 character. at least 8 character is this :

            if(7

            but for second part of your question ... ! try to understand these codes and get some idea to mke your own .never copy and paste!(just a suggestion to improve your skills,ofcourse you are free to copy :) )

            char[] Digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
            if (7 < password.Length)
            foreach (char t in Digits)
            if (password.Contains(t))
            for (int h = 65; h < 90; h++)
            if (password.Contains((char)h))
            break;//do proper operation ... .

            J 1 Reply Last reply
            0
            • P PIEBALDconsult

              You need to read his earlier post. It's homework.

              D Offline
              D Offline
              dusty_dex
              wrote on last edited by
              #6

              Ah, yes. missed that other post. :-O It's his own problem if he can't be bothered to *learn* and just copies stuff.

              Q. Hey man! have you sorted out the finite soup machine? A. Why yes, it's celery or tomato.

              1 Reply Last reply
              0
              • A ali_heidari_

                hi . if(password.Length < 8) is extreme 7 character. at least 8 character is this :

                if(7

                but for second part of your question ... ! try to understand these codes and get some idea to mke your own .never copy and paste!(just a suggestion to improve your skills,ofcourse you are free to copy :) )

                char[] Digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
                if (7 < password.Length)
                foreach (char t in Digits)
                if (password.Contains(t))
                for (int h = 65; h < 90; h++)
                if (password.Contains((char)h))
                break;//do proper operation ... .

                J Offline
                J Offline
                jschell
                wrote on last edited by
                #7

                In C# System.Char has a number of methods including isDigit()and isLetter()

                A 1 Reply Last reply
                0
                • J jschell

                  In C# System.Char has a number of methods including isDigit()and isLetter()

                  A Offline
                  A Offline
                  ali_heidari_
                  wrote on last edited by
                  #8

                  yea , its more simple way . thanks for remind!

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups