小编jem*_*n80的帖子

VS Code 中的 Hugo 模板格式

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)

有什么办法可以防止这种情况吗?

hugo visual-studio-code

5
推荐指数
1
解决办法
1001
查看次数

实现接口

我对接口的实现感到困惑.

根据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)

上面的代码有效.

-题-

我想实现接口必须实现每个属性类,所以为什么不testCollectionIsReadOnly,除非你将它转换为财产ICollection<string>

.net c# inheritance interface

4
推荐指数
1
解决办法
138
查看次数

标签 统计

.net ×1

c# ×1

hugo ×1

inheritance ×1

interface ×1

visual-studio-code ×1