我在visual studio 2019中编写了以下代码,但它给了我一个错误:BitVector32是一个名称空间,但在这里用作类型,而BitVector32命名空间中不存在CreateMask()方法。
using System;
using System.Collections.Specialized;
namespace BitVector32
{
class Program
{
static void Main(string[] args)
{
basicVector();
}
public static void basicVector()
{
BitVector32 b = new BitVector32(0);
int myBit1 = BitVector32.CreateMask();
int myBit2 = BitVector32.CreateMask(myBit1);
int myBit3 = BitVector32.CreateMask(myBit2);
int myBit4 = BitVector32.CreateMask(myBit3);
int myBit5 = BitVector32.CreateMask(myBit4);
}
}
}我在https://learn.microsoft.com/en-us/dotnet/api/system.collections.specialized.bitvector32?view=netcore-3.1上引用了Microsoft文档,并做了同样的操作,但它提供了上述错误。
发布于 2020-08-03 07:40:44
这是由于您位于顶部的名称空间是BitVector32。将命名空间更改为BitVector32以外的其他名称
using System;
using System.Collections.Specialized;
namespace SomethingOtherThanBitVector32
{
class Program
{
static void Main(string[] args)
{
basicVeector();
}
public static void basicVeector()
{
BitVector32 b = new BitVector32(0);
int myBit1 = BitVector32.CreateMask();
int myBit2 = BitVector32.CreateMask(myBit1);
int myBit3 = BitVector32.CreateMask(myBit2);
int myBit4 = BitVector32.CreateMask(myBit3);
int myBit5 = BitVector32.CreateMask(myBit4);
}
}
}https://stackoverflow.com/questions/63225479
复制相似问题