Click here to Skip to main content
15,561,125 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I using code vb.net, the example is
VB
Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
            If e.CommandLine.Count > 0 AndAlso e.CommandLine(0) = "-p" Then
                NEC.bSetupMode = False
                NEC.bManualMode = False
                If e.CommandLine.Count = 2 Then
                    NEC.sDayEndID = e.CommandLine(1)
                End If
            ElseIf e.CommandLine.Count > 0 AndAlso e.CommandLine(0) = "-m" Then
                NEC.bSetupMode = False
                NEC.bManualMode = True
            End If
        End Sub

I want using this code, but must convert to c#, How to do it
Thanks for help me.
Posted
Comments
sivasankari ts 21-May-12 22:57pm    
you want this code to be converted to c#

As explained here http://msdn.microsoft.com/en-us/library/ff664430(v=pandp.50).aspx[^] the procedure for handling the start up of application is different in C# and VB. In C# the above code is to be handled in Main method as shown below:
C#
static class Program {
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main(string[] args) {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        if (args.Length > 0 && args[0] == "-p") {
            NEC.bSetupMode = false;
            NEC.bManualMode = false;
            if (args.Length == 2) {
                NEC.sDayEndID = args[1];
            }
        } else if (args.Length> 0 && args[0] == "-m") {
            NEC.bSetupMode = false;
            NEC.bManualMode = true;
        }
        Application.Run(new Form1());
    }
}

To specify the command line arguments for a Windows Forms application in Debug mode in Visual Studio right click on the Startup Project in the Solution Explorer, select Properties menu option and then enter command line arguments in the Debug page.
 
Share this answer
 
Comments
Tuanth 21-May-12 23:36pm    
Thank you so much :D
VJ Reddy 21-May-12 23:41pm    
You're welcome and thank you for the response :)
If the solution is helpful then you may vote and accept the solution.
VJ Reddy 22-May-12 0:12am    
Thank you for accepting the solution :)
Tuanth 22-May-12 0:17am    
You're welcome :D
P.Salini 22-May-12 0:38am    
my +5
C#
private void MyApplication_Startup(object sender, Microsoft.VisualBasic.ApplicationServices.StartupEventArgs e)
{
    if (e.CommandLine.Count > 0 && e.CommandLine(0) == "-p") {
        NEC.bSetupMode = false;
        NEC.bManualMode = false;
        if (e.CommandLine.Count == 2) {
            NEC.sDayEndID = e.CommandLine(1);
        }
    } else if (e.CommandLine.Count > 0 && e.CommandLine(0) == "-m") {
        NEC.bSetupMode = false;
        NEC.bManualMode = true;
    }
}
 
Share this answer
 
Comments
Tuanth 21-May-12 22:59pm    
I trying this solution but can't use that, please support me other solution
The Microsoft.VisualBasic.ApplicationServices.StartupEventArgs can't use.
Thanks,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900