【发布时间】:2011-05-12 06:46:27
【问题描述】:
可能重复:
C# equivalent for Visual Basic keyword: 'With' ... 'End With'?
VB.NET
With Alpha.Beta.Gama.Eta.Zeta
a = .ZetaPropertyA
b = .ZetaPropertyB
c = .ZetaPropertyC
End With
C#?
a = Alpha.Beta.Gama.Eta.Zeta.ZetaPropertyA
b = Alpha.Beta.Gama.Eta.Zeta.ZetaPropertyB
c = Alpha.Beta.Gama.Eta.Zeta.ZetaPropertyC
【问题讨论】:
-
不,使用的是实现
IDisposeable的类。 -
我在一英里外就能闻到
Alpa.Beta.Gama.Eta.Zeta.ZetaPropertyA。如果您必须跨越这么多关系来设置属性,那么您的架构可能有问题。 -
spender:或具有树状对象结构的映射器。
-
@spender - 这被称为得墨忒耳法则:en.wikipedia.org/wiki/Law_of_Demeter
-
@spender:
GlobalProperties.Application.User.CurrentUser.TextOptions.WelcomeFontColor
标签: c# .net vb.net c#-4.0 vb.net-to-c#