|
-
February 6th, 2003, 01:20 PM
#1
How to I acheve the same effect as &(int) in C#
In C++, we can do this,
void SomeFunctions(int &a){...}
But in C#, I used,
public SomeFunctions(ref int a) and the compiler says invalid argument.
i.e.
...
int x=0;
SomeFunctions(x);
...
Then I tried this,
public SomeFunction(ref Object a) and the compiler says cannot convert Object from int.
I thought C# is able to auto-box int to an Object?
So now, I'm jammed here, how should I proceed?
end------------------------------
Programmers aren't born, but are made from hardwork, effort and time.
To be a good one, requires more effort and hardwork.
Therefore N quality programmer = (N*hardwork)+(N*effort)+(N*time)
-
February 6th, 2003, 01:29 PM
#2
no u keep method as it is
and pass as
SomeMethodCall(ref a) ;
like that
Paresh
-
February 6th, 2003, 08:43 PM
#3
forgot to mention
public void DrawAppointment(ref int abc)
{
x = x * x;
}
would be called as
int x = 10;
DrawAppointment(ref x);
now x will have 100;
Paresh
-
February 6th, 2003, 10:30 PM
#4
Oh my GOD! I can't believe I'm making such a careless mistake!
I called using "someFunctions(x)" where it should be "SomeFunctions(ref x)".
Thanks for the enlightenment.
end------------------------------
Programmers aren't born, but are made from hardwork, effort and time.
To be a good one, requires more effort and hardwork.
Therefore N quality programmer = (N*hardwork)+(N*effort)+(N*time)
-
February 7th, 2003, 12:05 PM
#5
no probs...
it happens.. but if you are compiling programs then you should check some syntaxes here and there. .since its just matter of testing ... :-)
Paresh
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|