Visual C# Developer Center > Visual C# Forums > Visual C# General > convert vb.net Chr(Int(Val("&H" & Mid(ftype, 3, 2)))) into c#
Ask a questionAsk a question
 

Answerconvert vb.net Chr(Int(Val("&H" & Mid(ftype, 3, 2)))) into c#

  • Friday, November 06, 2009 6:32 PMhazz Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    is the following c#

    packet.Append((char)Conversion.Val("&H" + Strings.Mid(ftype,1,2)));

    equivalent to the following vb.net?

    packet = packet & Chr(Int(Val("&H" & Mid(ftype, 3, 2))))

    Thank you,

Answers

  • Saturday, November 07, 2009 12:16 AMDavid Anton Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    No - you have no conversion of the "Int" call.
    The closest is:
    packet = packet + ((char)((int)Math.Floor(Microsoft.VisualBasic.Conversion.Val("&H" + ftype.Substring(2, 2))))).ToString();
    
    Also, there's no need to use the VB "Mid" function - "Substring" works fine here.
    Convert between VB, C#, C++, & Java (http://www.tangiblesoftwaresolutions.com)
    • Marked As Answer byhazz Saturday, November 07, 2009 1:24 PM
    •  

All Replies