title: Comparing securestring from inputfield with database in c#
body: <p>XMAL</p>
  
  <pre><code>&lt;PasswordBox PasswordChar="*" PasswordChanged="PasswordBox_PasswordChanged" Background="#545d6a" Foreground="White" FontSize="18"/&gt;
  </code></pre>
  
  <p>Code behind</p>
  
  <pre><code>private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
      {
          if (this.DataContext != null)
          { ((dynamic)this.DataContext).SecurePassword = ((PasswordBox)sender).SecurePassword; }
      }
  </code></pre>
  
  <p>I have a class Klant with a property Paswoord that i want to compare with the secureString.</p>
  
  <p>ViewModel</p>
  
  <pre><code>public SecureString SecurePassword { private get; set; }
  
  Klant = DataBaseOperations.OphalenKlantViaUsername(UserName);
              if (Klant != null)
              {
                  if (Klant.Paswoord == SecurePassword.ToString())
                  {
                      the password is correct and the program continues
                  }
                  else
                  {
                      MessageBox.Show("the password is incorrect");
                  }
              }
              else
              {
                  User does not exist.
              }
  </code></pre>
  
  <p>Can somebody help me?</p>