Compare two SPUser variable
-
03-10-2020 - |
Domanda
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)
{
}
Soluzione
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.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange