iHandler

May I know how to convert the following PHP code to C# I hope some C# experts can help here, thank you!

Code Snippet

$tmp = substr(chunk_split('1234123412341234', 1, ':'), 0, -1);
$Split = split('[:]' , $tmp);
$First[1] = $Split[0];
$First[2] = $Split[4];
$First[3] = $Split[8]; <---------this is be 8
$First[4] = $Split[12];
$Change = 0;
while ($Change < 4)
{
$Change = $Change + 1;
if ($First[$Change] > 0)
{
$First[$Change] = $First[$Change] - 1;
}
else
{
$First[$Change] = 9;
}
}
$Split[0] = $First[1];
$Split[4] = $First[2];
$Split[8] = $First[3]; <---------this is be 8
$Split[12] = $First[4];
$Count = 0;
$CC = '';
while ($Count < count($Split))
{
$CC .= $Split[$Count];
$Count = $Count + 1;
}

Please advise



(Moderator Use the code block button by highlighting text then select {} button)



Re: Visual C# Language Is is possible to do it in C#?

RizwanSharp

You better String functions available in .Net.

Functions like, String.Split(), String.Substring(), String.StartsWith() etc will help you in code translation.

I hope this will help.

Best Regards,

Rizwan aka RizwanSharp






Re: Visual C# Language Is is possible to do it in C#?

OmegaMan

I wouldn't be enamored in trying to do a 1 to 1 conversion....

The better question is what is the function trying to do It takes in information and parses it...what is the data that comes in and what is the data that goes out If you can determine that, then determine what in C# can achieve the goal.

It looks like a regular expression could parse the data more efficiently than working in a buffer by hand. If you know the input and output let us know ...