Compare two SPUser variable
-
03-10-2020 - |
Question
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)
{
}
Solution
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange