Is there a way to use SPSecurity.RunWithElevatedPrivileges conditionally. For example, assume that i have a code block, if some condition is met i want to run this code block in SPSecurity.RunWithElevatedPrivileges, otherwise i want to run this code block without SPSecurity.RunWithElevatedPrivileges
Put your code in a method with the VOID return (required by the delegate). Afterwards, use the if to determine your condition, and the actual method.
//Run the MyElevatedFunctionCall function with elevated priviledges SPSecurity.CodeToRunElevated elevatedCall = new SPSecurity.CodeToRunElevated(MyElevatedFunctionCall);