其中之一肯定更快吗?
var scan0 = (uint*)bitmapData.Scan0;
int length = pixels.Length;
for (int i = 0; i < length; i++)
{
uint j = scan0[i];
float a = (j >> 24) / 255f;
pixels[i] = new Vector(
(j >> 16 & 0xff) * a / 255,
(j >> 8 & 0xff) * a / 255,
(j & 0xff) * a / 255);
}
Run Code Online (Sandbox Code Playgroud)
相对
var scan0 = (byte*)bitmapData.Scan0;
int length = pixels.Length * 4;
for (int i = 0; i < length; …Run Code Online (Sandbox Code Playgroud) 写作很乏味
string msg = "Result is " + r.ToString(CultureInfo.InvariantCulture) + " with "
+ p.toString(CultureInfo.InvariantCulture) + "% probability.";
Run Code Online (Sandbox Code Playgroud)
我会比较喜欢
string msg = "Result is " + r + " with " + p + "% probability.";
Run Code Online (Sandbox Code Playgroud)
如何InvariantCulture在整个项目中将其设置为默认值?
我的目标是生成程序员可读的输出.
我觉得很多类(例如TcpClient,UdpClient,HttpListener)会一直更容易理解,如果他们是事件驱动使用.并且IAsyncResult模式实现起来非常困难,因为它可以让您了解各种奇怪的用例:
等等.尽管如此,微软还是选择在大多数地方使用它.为什么?
编辑:请集中讨论.NET 2.0,因为这是我必须使用的.
.net ×2
.net-2.0 ×1
c# ×1
color-space ×1
colors ×1
iasyncresult ×1
optimization ×1
srgb ×1
tostring ×1