Q# project and solution is created using the following commands:
dotnet new console -lang Q# --output FirstQuantum
Visual Studio Code is used to open the project. The project will have two files Driver.cs
(C# driver) and Operations.qs
(Q#). The Operations.qs
is renamed as Quantum.qs
.
The code snippet below shows the Quantum.qs
after adding the operation HelloWorld
.
Code Snippet :Quantum Q#Example
namespace FirstQuantum { open Microsoft.Quantum.Canon; open Microsoft.Quantum.Primitive; /// HelloWorld Operation /// # Summary /// prints the message /// # Returns /// a Unit operation HelloWorld () : Unit { Message("Q# - Hello World"); } }
The Driver file will have the following code to execute HelloWorld
.
Code Snippet :Driver C# Example
///////////////////////////////////////////////////////////////////// // This file contains the driver class. ////////////////////////////////////////////////////////////////////// using...