How to translate VB.Net CType () in C #

I have this code segment in VB NET :

 CType(pbImageHolder.Image, Bitmap).SetPixel(curPoint.X, curPoint.Y, Color.Purple) 

What is the corresponding code in C# ?

Thanks in advance.

+7
source share
3 answers

In VB.Net CType(object, type) , an object is transferred to a specific type.

In C #, you can do two ways:

 Bitmap image = pbImageHolder.Image as Bitmap; image.SetPixel(curPoint.X, curPoint.Y, Color.Purple); 

or

 Bitmap image = (Bitmap)(pbImageHolder.Image); image.SetPixel(curPoint.X, curPoint.Y, Color.Purple); 
+19
source
 ((Bitmap)pbImageHolder.Image).SetPixel(curPoint.X, curPoint.Y, Color.Purple) 
+9
source

Hi, this is the code after converting VB to C # code:

 ((Bitmap)pbImageHolder.Image).SetPixel(curPoint.X, curPoint.Y, Color.Purple); 

And if you want to convert code from VB to C # and vice versa, follow this link: http://www.developerfusion.com/tools/convert/vb-to-csharp/

+2
source

All Articles