I am converting a vb6 app into c# and I've come across something I don't quite understand. I've never seen an if statement structure where the expression being evaluated is literally "true" or "false".
private bool InitializeForProgramming() //OK
{
if (J1939.getReplyStatus() == modJ1939.dmOpFailed) //or OpComplete (dmBusy auto cycles)
{
//check the Pointer value to see if engineRunning, or already in Mode
if (true) //let it proceed *** ??
{
//nothing to do
}
else
{
lblCommun.Text = "ProgramMode Failed!";
lblCommun.ForeColor = Color.Red;
//could report more detailed reasons! (engineRunning, etc.)
return true; //FAILED!
}
}
What is being evaluated here with the expression if(true)? If what is true?
Here is the original vb6 code:
Private Function InitializeForProgramming() As Boolean 'OK
If getReplyStatus = dmOpFailed Then 'or OpComplete (dmBusy auto cycles)
'check the Pointer value to see if engineRunning, or already in Mode
If (True) Then 'let it proceed *** ??
'nothing to do
Else
txtCommun.Text = "ProgramMode Failed!"
txtCommun.ForeColor = vbRed
'could report more detailed reasons! (engineRunning, etc.)
InitializeForProgramming = True 'FAILED!
Exit Function
End If
End If
Please let me know if you need me to include anything else to help me get an answer.
Most likely this is the result of a condition that was removed in the past. I.e. there used to be a condition in the if, but not any longer. You should check the source control history for changes to that line.
You can just remove the whole if statement in this case for your rewrite. Also C# probably complains that not all code paths return a value from the method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With