Link to home
Start Free TrialLog in
Avatar of radhakrishan
radhakrishan

asked on

VB.NET to C#

Hello Experts,

I am new to C# could anyone pls tell me how to convert the following function from VB to C#

 Private Function Msgbox(ByVal strMessage As String)

        Dim strScript As String = "<script language=JavaScript>"
        strScript += "alert(""" & strMessage & """);"
        strScript += "</script>"

        If (Not Page.IsStartupScriptRegistered("clientScript")) Then
            Page.RegisterStartupScript("clientScript", strScript)
        End If

    End Function

Also:

            Dim dt As DateTime
            Dim dt1 As DateTime
            dt = New DateTime(sy, sm, sd, sh, smm, 0)
            dt1 = New DateTime(ey, em, ed, eh, emm, 0)

Any help appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
private void MsgBox(string strMessage)
{
     string strScript = "<script language=JavaScript>";
     strScript += "alert(\"" + strMessage + "\");";
     strScript += "</script>";

     if (!Page.IsStartupScriptRegistered("clientScript"))
     {
          Page.RegisterStartupScript("clientScript", strScript)
     }
}


DateTime dt = new DateTime(sy, sm, sd, sh, smm, 0);
DateTime dt1 = new DateTime(ey, em, ed, eh, emm, 0);
Second part:

    DateTime dt = new DateTime(sy, sm, sd, sh, smm, 0);
    DateTime dt1 = new DateTime(ey, em, ed, eh, emm, 0);
sorry carl, posted on same minute!
Avatar of radhakrishan
radhakrishan

ASKER

Hi Guys,

Thanks for the reply.

In the 2nd Part:

DateTime dt = new DateTime(sy, sm, sd, sh, smm, 0);
DateTime dt1 = new DateTime(ey, em, ed, eh, emm, 0);

I get an error on each argument cannot convert string to int.

Should I be writing somthing like int.Parse(sy)
If your variables are strings containing ints then yes.
Yeah,
Thanks for the reply.
Thanks for the points, although I think a Split may have been more appropriate since Zephyr and myself posted the same answer at the same time.

Post a request in Community Support if you want to change the point split.