Search code examples
c#.netx509certificate2

What is this "|" (pipe) means in C#?


In the context of Security Cryptography X509Certificates, I've came across this in one of the projects code.

X509Store store = new X509Store("MY", StoreLocation.CurrentUser);
store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite);

What is this "|" pipe means here?


Solution

  • It's a bitwise OR operator. In this case, it is used to combine flags. Meaning you open the store in Read/Write mode and only if it already exists. There's more explanation on bitwise operators on MSDN.