【发布时间】:2011-08-25 09:23:38
【问题描述】:
我有这样的课程:
class Foo
private shared default_ = "DEFAULT"
public shared function bar(val as object) as string
if val is Nothing then return _default
return getBar(val)
end function
private shared function getBar(val as string) as string
return formatString(val)
end function
private shared function getBar(val as System.Int32) as string
return formatInt(val)
end function
end class
formatString 和 FormatInt 是公共共享方法。 当我调用 Foo.bar 时,我得到一个 MissingMemberException:
System.MissingMemberException: Public member 'getBar' on type 'Foo' not found.
当我公开 getBar 方法时,它可以工作,但我不想不必要地公开这些方法。为什么我不能从同一类中的公共方法调用私有共享方法,这让我无法理解。
我在 Web 应用程序中使用 .net framework 4.0。
【问题讨论】:
-
看到几乎所有内容都以小写字母开头的 VB 代码感觉很奇怪。
-
@BoltClock - 就像 VB 想要成为 C# 一样,反之亦然? :)
-
嗯,VB.Net 最好的一点是,我不必遵循 M$ 编码风格... :)