VS Code 中的自动格式通过删除缩进使我的代码不可读。我不知道如何仅对车把关闭此功能。
输入:
{{ range ... }}
{{ if .... }}
{{if ... }}
<tag></tag>
{{end}}
{{end}}
{{end}}
Run Code Online (Sandbox Code Playgroud)
输出
{{ range ... }}
{{ if .... }}
{{if ... }}
<tag></tag>
{{end}}
{{end}}
{{end}}
Run Code Online (Sandbox Code Playgroud)
有什么办法可以防止这种情况吗?
我对接口的实现感到困惑.
根据MSDN ICollection<T>的财产IsReadOnly
-和-
根据MSDN Collection<T>实现ICollection<T>
-所以-
我以为那Collection<T>会有财产IsReadOnly.
-然而-
Collection<string> testCollection = new Collection<string>();
Console.WriteLine(testCollection.IsReadOnly);
Run Code Online (Sandbox Code Playgroud)
上面的代码给出了编译错误:
'System.Collections.ObjectModel.Collection<string>' does not contain a definition for 'IsReadOnly' and no extension method 'IsReadOnly' accepting a first argument of type
'System.Collections.ObjectModel.Collection<string>' could be found (are you missing a using directive or an assembly reference?)
-而-
Collection<string> testInterface = new Collection<string>();
Console.WriteLine(((ICollection<string>)testInterface).IsReadOnly);
Run Code Online (Sandbox Code Playgroud)
上面的代码有效.
-题-
我想实现接口必须实现每个属性类,所以为什么不testCollection有IsReadOnly,除非你将它转换为财产ICollection<string>?