【发布时间】:2012-08-27 13:54:34
【问题描述】:
我需要在 Flex 中将像“ff5ac81c-fc51-9442-b993-60cff48c6b39”这样的 UID 转换为十六进制字符串。 在 C# 中,我可以像这样使用格式参数:
public static string GuidToHex(Guid guid) {
return ByteToHex(guid.ToByteArray());
}
public static string ByteToHex(byte[] bytes) {
StringBuilder sb = new StringBuilder(bytes.Length * 2);
foreach (byte b in bytes) {
sb.AppendFormat("{0:x2}", b);
}
return sb.ToString().ToUpper();
}
如何在动作脚本中做到这一点?
【问题讨论】:
-
您是否要求我们为您转换该代码?还是希望我们向您描述算法?还是别的什么?
-
先转换代码。如果我知道带有参数“{0:x2}”的 appendFormat-Method 内部发生了什么 - 更好
-
我也不知道会发生什么;但我不确定为什么你不能谷歌它并弄清楚该方法的作用。这就是我必须做的。
-
我做了几个小时......我没有找到任何东西
-
这里是 StringBuilder.AppendFormat 上的文档:msdn.microsoft.com/en-us/library/…。它应该给你一个起点。
标签: apache-flex actionscript hex guid uid