# How can I transform a Result into a Bool in Q# + C# environment?

I'm writing a Q# program and I'm calling an operation defined in the program that outputs a Result (One or Zero).

For example something like this:

output = QuantumOperation.Run(sim).Result;


I want to convert now output to a bool within C#, but I don't know how.

One way to go around this is to change the output of QuantumOperation to be a bool and transforming the result at the end of the operation with ResultAsBool(result). However, I want to maintain the output of the operation to be a Result. So ideally the conversion should happen within the C# host code.

Q# type Result is represented by C# class Microsoft.Quantum.Simulation.Core.Result; in particular, it has constants Result.Zero and Result.One that you can compare the return of your operation to.
using Microsoft.Quantum.Simulation.Core;