# How to retrieve the parameters of a Q# operation?

How to retrieve the parameters of a Q# operation? Is it possible to do such a thing at all?

• This question seems similar to stackoverflow.com/questions/59022076/… - does the answer to that one help you? (I haven't tried doing that kind of thing myself so can't be sure) – Mariia Mykhailova Feb 17 at 19:20
• @MariiaMykhailova That answer needs more explanation, what is IQ# been mentioned there? Does it help? – Coder Feb 17 at 19:31
• IQ# is the Jupyter kernel for Q#. You can look at the source at github.com/microsoft/iqsharp. The file src\Core\OperationInfo.cs builds a list of the parameter types using reflection on the Run method of the generated class. – Alan Geller Feb 19 at 18:37

You are assuming a 1-1 mapping from a Q# operation with a C# operation but it doesn't work like that. A Q# operation can have a lot more functionality than a C# class, for example, Q# offers the ability to automatically create the adjoint and controlled versions of a the operation.
Each Q# operations generations a C# class that extends the generic class Operation<I,O>, so to figure out what the input/output parameters you can take a look at the BaseType of the operation's Type, and look at the value of the GenericTypeArguments[0] to figure out the input type.