简体   繁体   English

直接访问pictureBox.Image

[英]Direct access to pictureBox.Image

I'm very frequently modifying an image within the picturebox so I though I would do something like this: 我经常在图片框内修改图片,因此尽管我会这样做:

modify(ref pictureBox1.Image);

unfortunately it doesn't work, it throws a following error "A property, indexer or dynamic member access may not be passed as an out or ref parameter". 不幸的是,它不起作用,并引发以下错误“属性,索引器或动态成员访问可能不作为out或ref参数传递”。 Ok, I get the error - but still is there any work around or something to speed up my program? 好的,我得到了错误-但是仍然有任何解决方法或可以加快程序速度的方法吗?

All objects (reference types) in .NET are passed by reference, there is no benefit in adding ref keyword. .NET中的所有对象(引用类型)都是通过引用传递的,添加ref关键字没有任何好处。 Try this: 尝试这个:

var image = pictureBox.Image;
modify(image);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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