Quantum Program The name 'BellTest' does not exist in the current context

sum*_*mar 6 c# quantum-computing q#

This is my first Q# program and i'm following this getting started link.https://docs.microsoft.com/en-us/quantum/quantum-writeaquantumprogram?view=qsharp-preview

Error is

The name 'BellTest' does not exist in the current context but its defined in the Bell.cs

I followed the steps and when building its having errors. I'm not sure how to import the operations from .qs file to driver c# file as this error looks like it can't find that operation.

Any help is really appreciated

Here is the code

Driver.cs

using Microsoft.Quantum.Simulation.Core;
using Microsoft.Quantum.Simulation.Simulators;

namespace Quantum.Bell
{
    class Driver
    {
        static void Main(string[] args)
        {
            using (var sim = new QuantumSimulator())
            {
                // Try initial values
                Result[] initials = new Result[] { Result.Zero, Result.One };
                foreach (Result initial in initials)
                {
                    var res = BellTest.Run(sim, 1000, initial).Result;
                    var (numZeros, numOnes) = res;
                    System.Console.WriteLine(
                        $"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4}");
                }
            }
            System.Console.WriteLine("Press any key to continue...");
            System.Console.ReadKey();

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Bell.qs

namespace Quantum.Bell
{
    open Microsoft.Quantum.Primitive;
    open Microsoft.Quantum.Canon;

    operation Set (desired:Result,q1:Qubit) : ()
    {
        body
        {

             let current = M(q1);

            if (desired != current)
            {
                X(q1);
            }

        }
    }

    operation BellTest (count : Int, initial: Result) : (Int,Int)
    {
        body
        {
            mutable numOnes = 0;
            using (qubits = Qubit[1])
            {
                for (test in 1..count)
                {
                    Set (initial, qubits[0]);

                    let res = M (qubits[0]);

                    // Count the number of ones we saw:
                    if (res == One)
                    {
                        set numOnes = numOnes + 1;
                    }
                }
                Set(Zero, qubits[0]);
            }
            // Return number of times we saw a |0> and number of times we saw a |1>
            return (count-numOnes, numOnes);
        }    
    }
}
Run Code Online (Sandbox Code Playgroud)

kot*_*tsu 3

我也遇到了同样的错误,但是我可以通过按该F5键来做到这一点。

也许 Visual Studio 编辑器尚未完全支持该.qs文件。.cs文件与文件之间的命名空间共享似乎无法正常工作.qs

我能够在我的开发环境中使用您的代码执行。

--

IDE:Visual Studio Community 2017(版本 15.5.2)
开发工具包:Microsoft Quantum 开发工具包(0 和 1)