Reputation: 11
I'm new c# and wpf. Currently I'm converting our old vb6 code to c#. How can i convert this piece of code to c#?
NOTE: I have multiple Forms to cater different payments w/c have different object and control in it. 1. dlgPaymentCash 2. dlgCard 3. dlgCheck
Dim dlgpayment As Form
Select Case paymentType
Case "CASH": Set dlgpayment = New dlgPaymentCash
Case "CARD": Set dlgpayment = New dlgCard
Case "CHECK": Set dlgpayment = New dlgPaymentCheck
End Select
Is this possible in c# and what is the best way?
Upvotes: 0
Views: 70
Reputation: 2891
It's been some time since I have programmed VB, but I guess you are on the right track with this code. Be aware that you probably will have to handle the default case (null) if paymentType might become something else than the existing choices.
Form dlgPayment = null;
switch (paymentType)
{
case "CASH": dlgpayment = new dlgPaymentCash();
break;
case "CARD": dlgpayment = new dlgCard();
break;
case "CHECK": dlgpayment = new dlgPaymentCheck();
break;
}
Even if VB6 is not .NET, anything is possible in C# also. There might be some additional effort however.
Upvotes: 1