New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Else if statement #4615
Comments
Yes we already support this. The Line 176 in a695486
You could write this in this way: var statement = new IfElseStatement(
new IfStatement(condition1)
{
// statements for your if
},
// this is the else statement
new IfStatement(condition2)
{
// statements for your first else if
})); This will write into: if (condition1)
{
// statements for your if
}
else if (condition2)
{
// statements for your first else if
} If you want more var statement = new IfElseStatement(
new IfStatement(condition1)
{
// statements for your if
},
// this is the else statement
new IfElseStatement(
new IfStatement(condition2)
{
// statements for your first else if
},
new IfElseStatement(
new IfStatement(condition3)
{
// statements for your second else if
},
new MethodBodyStatement[] {
// statements for your else
}))); this will write:
|
I must be doing something wrong - https://github.com/Azure/autorest.csharp/pull/4649/files#diff-e951b5dd9fe84a348c5597b47c30f38972a39dce8d6659979415eafff9ac77daR292 |
yes from the generated code, we are having: if (...)
{
// ...
}
else
{
if (...)
{
// ...
}
} which just works but it is not ideal, somewhere is wrong. |
Is there any support for writing an if else statement like this (inlining the second if statement so that it is an else if)
I couldn't figure out how to do this using an IfElseStatement. Can this be supported?
The text was updated successfully, but these errors were encountered: