No warning in VB.NET when function has no return

前端 未结 5 2019
梦如初夏
梦如初夏 2020-12-06 19:47

Some comments on Stack Overflow question Why doesn\'t the C# compiler stop properties from referring to themselves? regarding warnings got me thinking about old issues that

5条回答
  •  心在旅途
    2020-12-06 20:10

    You aren't necessarily asking for a workaround, but I'm just thinking out loud: You could make the return type of the function Nullable.

    At runtime, if the function reflects Nothing, you know the programmer didn't explicitly assign a return value. Of course this only works for functions that don't naturally return Nothing. And it's inefficient in many ways.

提交回复
热议问题