如何将VB.Net的CType()转换为C#
我在VB NET
有这段代码:
CType(pbImageHolder.Image, Bitmap).SetPixel(curPoint.X, curPoint.Y, Color.Purple)
什么是C#
适当代码?
先感谢您。
在VB.Net中, CType(object, type)
将对象强制转换为特定类型。
在C#中有两种方法可以实现这一点:
Bitmap image = pbImageHolder.Image as Bitmap; image.SetPixel(curPoint.X, curPoint.Y, Color.Purple);
要么
Bitmap image = (Bitmap)(pbImageHolder.Image); image.SetPixel(curPoint.X, curPoint.Y, Color.Purple);
((Bitmap)pbImageHolder.Image).SetPixel(curPoint.X, curPoint.Y, Color.Purple)
嗨,这是将VB转换为C#代码后的代码:
((Bitmap)pbImageHolder.Image).SetPixel(curPoint.X, curPoint.Y, Color.Purple);
如果你想要从VB到C#的代码转换,反过来请通过以下链接: http : //www.developerfusion.com/tools/convert/vb-to-csharp/