peter70 peter70 - 1 year ago 109 Question

Mid as target of an assignment

I try just an old VB application in c# to convert, while I've encountered this line of code:

Mid(strData, intPosition + 1, intLenght) = strValue

How can it be translated into c#?

Answer Source

You would have to combine Remove and Insert, something like:

strData.Remove(intPosition, intLenght).Insert(intPosition, strValue);

The above assumes that the length of strValue was equal to intLenght. If strValue might be longer, then to replicate the Mid statement, we would need to do:

strData.Remove(intPosition, intLenght)
       .Insert(intPosition, strValue.Substring(0, intLenght));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download