Link to home
Start Free TrialLog in
Avatar of Seven price
Seven priceFlag for United States of America

asked on

convert to c# byte

the conversion keep adding strings for this conversion.which is wrong.

  Function MakeByte(ByVal text As String) As Byte()

        Dim i As Integer
        Dim ba(text.Length - 1) As Byte
        For i = 1 To Len(text)
            ba(i - 1) = Asc(Mid(text, i, 1))
        Next

        Return ba

    End Function

Open in new window

Avatar of Ess Kay
Ess Kay
Flag of United States of America image

Dont see a problem

User generated image
Avatar of Seven price

ASKER

I want it to convert to c# version. sorry
you mean you want the same code in c#?

public byte[] MakeByte(string text)
{

	int i = 0;
	byte[] ba = new byte[text.Length];
	for (i = 1; i <= Strings.Len(text); i++) {
		ba[i - 1] = Strings.Asc(Strings.Mid(text, i, 1));
	}

	return ba;

}

Open in new window

you use converter and Strings.Le and Strings.Asc(Strings
do not exists in the current context.
ASKER CERTIFIED SOLUTION
Avatar of Ess Kay
Ess Kay
Flag of United States of America 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
tks