It sounds like you're really asking about how to measure in a given Pauli basis. (I'm assuming for simplicity that you are working with only a single qubit, but the below is generalizable to multiple qubits as well.)
Q# has a Measure operation which performs a measurement in a given Pauli basis. For example, if you have a
q in some state $|\psi\rangle$ and you want to measure it in the $X$ basis, you can write:
let result = Measure([PauliX], [q]);
result will be either
One. If you want to then estimate the expectation value of the measurement, you would need to repeat your full operation (including whatever you did to prepare your qubit in the state $|\psi\rangle$) many times and take an average of the measurement results.