Allow return void
#7862
-
void Func1() { }
void Func2()
{
if (...)
return Func1();
// This is equivalent to
if (...)
{
Func1();
return;
}
...
} |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
See: #135 |
Beta Was this translation helpful? Give feedback.
-
Perhaps this feature could work sort of like the |
Beta Was this translation helpful? Give feedback.
-
I hope
Of course, I know that
|
Beta Was this translation helpful? Give feedback.
-
Hello It would be great if we could return a void method (and even a value) in another void method. Example: Please see the following codes in C# language: public void PageLoad(HttpContext context)
{
if (!string.IsNullOrEmpty(context.Request.Form["btn_Delete"]))
{
btn_Delete_Click(context);
return;
}
if (!string.IsNullOrEmpty(context.Request.Form["btn_GoToEdit"]))
{
btn_GoToEdit_Click(context);
return;
}
// Do something
}
private void btn_Delete_Click(HttpContext context)
{
// Do something
}
private void btn_GoToEdit_Click(HttpContext context)
{
// Do something
} Now compare the codes below with the codes above: public void PageLoad(HttpContext context)
{
if (!string.IsNullOrEmpty(context.Request.Form["btn_Delete"]))
return btn_Delete_Click(context);
if (!string.IsNullOrEmpty(context.Request.Form["btn_GoToEdit"]))
return btn_GoToEdit_Click(context);
// Do something
}
private void btn_Delete_Click(HttpContext context)
{
// Do something
}
private void btn_GoToEdit_Click(HttpContext context)
{
// Do something
} If this feature is added to C#, the codes will be cleaner. |
Beta Was this translation helpful? Give feedback.
See: #135