从 System.Drawing.Brushes 获取名称和类型的配对列表
我想创建一个 BrushInfo 列表,其中包含 System.Drawing.Brushes 中的画笔名称及其类型的属性。类似于:
Dim brushList = GetType(Drawing.Brushes) _
.GetProperties.Select(Function(p) New BrushInfo With
{.BrushName = p.Name, .BrushValue = GetType(p)})
上面的代码将获取画笔的名称(p.Name),但不会获取画笔的类型(即System.Drawing.Brushes.AliceBlue)。如何获取画笔类型?
I want to create a list of BrushInfo which has properties of a brush name and its type from System.Drawing.Brushes. Something like:
Dim brushList = GetType(Drawing.Brushes) _
.GetProperties.Select(Function(p) New BrushInfo With
{.BrushName = p.Name, .BrushValue = GetType(p)})
The code above will get me the name of the brush (p.Name) but will not get me the type of the brush (i.e. System.Drawing.Brushes.AliceBlue). How do I get the brush type?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您想要获取属性的值,而不是属性的类型。代替:
使用:
You want to get the value of the property, not the type of the property. Instead of:
use:
Brush
类型为Brush
。Brush
的名称只是因为它是Brushes
中该名称的属性。除了Brush
之外,Brush
本身没有其他类型或名称。The
Brush
type isBrush
. The name of theBrush
is only by virtue of it being a property of that name inBrushes
. TheBrush
itself has no further type or name beyondBrush
.