谢谢你反馈。它确实在所有情况下分配它,但这就是为什么 我认为它是一个错误。 Hi there,Before I notify MSFT, can someone confirm this is in fact a compiler bug (itseems pretty obvious but I''m fairly new to C#). The following code(erroneously) generates compiler error CS0177 (The out parameter ''Whatever''must be assigned to before control leaves the current method).public void SomeFunc(out string Whatever){bool Continue = ShouldWeContinue();if (Continue){Whatever = "Continue";}if (!Continue){Whatever = "Didn''t continue";}} 解决方案Thanks for the feedback. It does assign it in all cases however which is whyI consider it a bug. 这篇关于请确认这是一个MSFT错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!