473,499 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A function with a Bitmap

What's happen exactly when I pass a Bitmap to a function in this way:

text_localization(EMP1);
public Bitmap text_localization( Bitmap EMP1 ) {}
??

It's the same thing to do this?

text_localization(ref EMP1);
public Bitmap text_localization( ref Bitmap EMP1 ) {}
--
RicercatoreSbadato
Nov 17 '05 #1
5 1295
When the ref keyword is present, you can change the reference passed to the
function.

Consider this sample :

void fct1()
{
ClassX obj1 = null;
Class obj2 = null;
fct(obj1, obj2);

// obj1 == null
// obj2 != null
}

void fct2(ClassX o1, ref ClassX o2)
{
if (o1 == null)
o1 = new ClassX();
if (o2 == null)
o2 = new ClassX();
}

Fabien

"RicercatoreSbadato" <Ri****************@nomail.it> a écrit dans le message
de news: X1*******************@tornado.fastwebnet.it...
What's happen exactly when I pass a Bitmap to a function in this way:

text_localization(EMP1);
public Bitmap text_localization( Bitmap EMP1 ) {}
??

It's the same thing to do this?

text_localization(ref EMP1);
public Bitmap text_localization( ref Bitmap EMP1 ) {}
--
RicercatoreSbadato

Nov 17 '05 #2
ok, but my question was on the Bitmap Class. What I pass when I do so:

text_localization(EMP1);
public Bitmap text_localization( Bitmap EMP1 ) {}

??

--
RicercatoreSbadato

Fabien Bezagu wrote:
When the ref keyword is present, you can change the reference passed to the
function.

Consider this sample :

void fct1()
{
ClassX obj1 = null;
Class obj2 = null;
fct(obj1, obj2);

// obj1 == null
// obj2 != null
}

void fct2(ClassX o1, ref ClassX o2)
{
if (o1 == null)
o1 = new ClassX();
if (o2 == null)
o2 = new ClassX();
}

Fabien

Nov 17 '05 #3
I'm a bit confused and perhaps I don't understand exactly what's your
problem.

Since Bitmap is a class, and thus a reference type, you pass the reference
to the instance when simply passing it as parameter without the ref keyword.
If the question was "Is there a new instance of Bitmap created ?", the
answer is clearly "no".

Hope this helps.

Fabien

"RicercatoreSbadato" <Ri****************@nomail.it> a écrit dans le message
de news: bG*******************@tornado.fastwebnet.it...
ok, but my question was on the Bitmap Class. What I pass when I do so:

text_localization(EMP1);
public Bitmap text_localization( Bitmap EMP1 ) {}

??

--
RicercatoreSbadato

Fabien Bezagu wrote:
When the ref keyword is present, you can change the reference passed to
the function.

Consider this sample :

void fct1()
{
ClassX obj1 = null;
Class obj2 = null;
fct(obj1, obj2);

// obj1 == null
// obj2 != null
}

void fct2(ClassX o1, ref ClassX o2)
{
if (o1 == null)
o1 = new ClassX();
if (o2 == null)
o2 = new ClassX();
}

Fabien

Nov 17 '05 #4
yes, that was the answer I was looking for.
thank you. ;)
--
RicercatoreSbadato

Fabien Bezagu wrote:
the answer is clearly "no".

Nov 17 '05 #5
Hi,

It's a subtle differece , for one of the best explanation aroudn read this :
http://www.yoda.arachsys.com/csharp/parameters.html

in short the difference is that when use the "ref" you can change to what
instance the variable EMP1 refers to.

and in both cases you can change the instance reference by EMP1.
read the article, it's crystal clear there.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"RicercatoreSbadato" <Ri****************@nomail.it> wrote in message
news:X1*******************@tornado.fastwebnet.it.. .
What's happen exactly when I pass a Bitmap to a function in this way:

text_localization(EMP1);
public Bitmap text_localization( Bitmap EMP1 ) {}
??

It's the same thing to do this?

text_localization(ref EMP1);
public Bitmap text_localization( ref Bitmap EMP1 ) {}
--
RicercatoreSbadato

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3738
by: sector119 | last post by:
I use python 2.4.1 and PIL 1.1.5 and when I execute my program I got error: ../code.py Traceback (most recent call last): File "./code.py", line 7, in ? class DrawPlus(ImageDraw.Draw):...
3
4901
by: Michael | last post by:
Hi developers, I downloaded the Canon SDK Version 7.1 and tried to migrate the "RELCTRL" sample to C# (with PInvoke). Almost everything is working except the following callback function that...
6
1509
by: Martin Holmgaard | last post by:
I have written the following function to be used for flood filling in a bitmap. The function works fine on Windows XP Prof and Windows 2000 server, but on Windows 2003 server it return a stack...
2
2629
by: Michael Murphy | last post by:
At the risk of being publically humiliated, might I ask the following simple question. I have a solution with one project. This project, WindowsApplication1, has one "form" and one "bitmap" (the...
3
2196
by: fripper | last post by:
Is there a way to use the windows bitblt function in a VB 2005 app? bitblt requires device context parameters for the source and destination controls but those are not used in VB 2005. Is there...
7
8217
by: Fir5tSight | last post by:
Hi All, I used the following code in C#: using System.Drawing; //blah blah blah Bitmap bmp = new Bitmap();
2
3463
by: Iwanow | last post by:
Hello! I have a single class without any inheritance over there, and I get that error on its constructor which is an empty function: LabelProcessor::LabelProcessor() { } The full error...
0
1500
MetalMartian
by: MetalMartian | last post by:
I'm trying to write code for a game based on the original Pacman in Visual Basic .NET 2003, however I can't figure out how to make the character move around the screen and not go through the walls....
2
1600
by: Mosfet | last post by:
Hi, I am currently writing a graphical control(a list control) that can display a picture followed by some text and to do so I first calculate an item height and then I really draw. I was...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6894
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7388
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4600
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3099
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3091
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.