我剛剛升級到VS2017,但馬上就關閉了,我的項目無法再生成,因爲我收到了一堆當我使用VS15時不存在的奇怪編譯器錯誤。Visual Studio 2017編譯器錯誤
錯誤如:
Syntax Error; value expected
Invalid Expression Term '['
Invalid Expression Term 'byte'
Using the generic type requires 1 type arguments
編輯1:
- 就創建了一個小型控制檯應用程序,並複製了一些代碼,並在相同的編譯器錯誤(S)的出現
using System;
using System.Runtime.InteropServices;
namespace Error
{
class Program
{
static void Main()
{
Array array2D = null;
if (array2D is Bgra <byte>[,])
{
}
}
}
public interface IColor { }
public interface IColor<T> : IColor
where T : struct
{ }
public interface IColor2 : IColor { }
public interface IColor2<T> : IColor2, IColor<T>
where T : struct
{ }
public interface IColor3 : IColor { }
public interface IColor3<T> : IColor3, IColor<T>
where T : struct
{ }
public interface IColor4 : IColor { }
public interface IColor4<T> : IColor4, IColor<T>
where T : struct
{ }
[StructLayout(LayoutKind.Sequential)]
public struct Bgra<T> : IColor4<T>
where T : struct
{
public Bgra(T b, T g, T r, T a)
{
B = b;
G = g;
R = r;
A = a;
}
public T B;
public T G;
public T R;
public T A;
public override string ToString()
{
return $"B: {B}, G: {G}, R: {R}, A: {A}";
}
public const int IDX_B = 0;
public const int IDX_G = 1;
public const int IDX_R = 2;
public const int IDX_A = 3;
}
}
需要注意的是完全相同的項目編譯在VS15甚至VS13沒關係。
你可以在一個小程序中重現錯誤? –
它是否指定了一行代碼「語法錯誤」應該是,如果是這樣的行? –
@MthetheWWatson#編輯 –