0

I validate two SPUser values inside if condition.

Both SPUser variables have values when my program runs, but when both SPUser values are same my app runs and enter inside if condition. Ideally it should not be.

Where I'm going wrong?

if (ownerUser != currentUser)
{
}

1 Answer 1

2

You can't compare Reference objects unless they implement IEquatable interface.

Or it should override equal method with custom implementation.

I would suggest you compare SPUser.LoginName instead.

2
  • Thanks for the quick response.. Seems you are correct. I'll try and let you know when I'm good... Commented May 11, 2015 at 14:54
  • Yes. It works. You are great.. Thanks @Amal Hashim Commented May 12, 2015 at 5:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.