All pastes #68818 Raw Edit

Miscellany

public text v1 · immutable
#68818 ·published 2006-06-22 03:47 UTC
rendered paste body
    public static byte[] StringToBytes(string textIn)
    {
      byte[] bs2;

      if (textIn == null)
      {
        return null;
      }
      byte[] bs1 = new UnicodeEncoding().GetBytes(textIn);
      float f1 = 0.0F;
      float f3 = Information.UBound(bs1, 1);
      for (float f2 = 0.0F; FlowControl.ForNextCheckR4(f2, f3, 1.0F); f2++)
      {
        if (bs1[(int)Math.Round((double)f2)] != 0)
        {
          bs2 = (byte[])Utils.CopyArray((Array)bs2, new byte[(int)Math.Round((double)f1) + 1]);
          bs2[(int)Math.Round((double)f1)] = bs1[(int)Math.Round((double)f2)];
          f1++;
        }
      }
      return bs2;
    }
  }