简体   繁体   中英

Why Graphics.FromImage(Bitmap myBitmap) update myBitmap

I have no problems , but I want to understand one thing for personal experience

var graphics = Graphics.FromImage(Bitmap myBitmap)
...
graphics.DrawImage(Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)

So , the question is : why after I called the function myBitmap was updated but FromImage() dont get ref or out attribute?

The Bitmap class is an reference type, so an reference (pointer) get passed by value.

Here's an explanation what C# is really doing: https://stackoverflow.com/a/9717120/4783560

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM