Allow return void
#7862
Answered
by
HaloFour
yuyang9119
asked this question in
Language Ideas
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.
Answered by
HaloFour
Jan 22, 2024
Replies: 4 comments 7 replies
-
See: #135 |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
svick
-
Perhaps this feature could work sort of like the |
Beta Was this translation helpful? Give feedback.
0 replies
-
I hope
Of course, I know that
|
Beta Was this translation helpful? Give feedback.
0 replies
-
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.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See: #135