Yello,
I am having a hard time converting
from vb to cs. I think that vb as
doing a little more behind the scenes,
than I relized...
The prob code:
vb---------------------------------
someMethod(nothing, 0,....,nothing)
-----------------------------------
cs---------------------------------
someMethod(null,0,...., null); //this does not work!!!
-----------------------------------
Seams easy enough, right?... but replacing
that "nothing" with "null" doesn't work due to
the argument being of a reference type.
Does that mean I would have to define, and
initiaize the arguments? I know if I redefine
the function in cs to use an "out" instead of
a "ref" var, that I would not have to initialize
the referenced variable.... but doesnt that mean
I would still have to define a variable?
Any suggestions as to the fastest and cleanest
way of getting the proper syntext for cs would be
greatly appreciated.
(example??)
thanks jamie
.. 2 924
Why exactly doesn't it work? What message are you getting? Is the error at
compile or runtime? Can we wee a little more of the code, enough to be able
to replicate the problem ourselves, thanks.
All that said, there is nothing wrong with passing a null in to a parameter
expecting a reference type. Be default the reference type is passed in by
value. Using the ref keyword merely means that the reference to the
reference type can be modified. Using the out keyword means the parameter
must be initialized by the method.
Have a look at http://www.yoda.arachsys.com/csharp/parameters.html for more
detail.
"jamie" <an*******@discussions.microsoft.com> wrote in message
news:0f****************************@phx.gbl... Yello, I am having a hard time converting from vb to cs. I think that vb as doing a little more behind the scenes, than I relized...
The prob code: vb--------------------------------- someMethod(nothing, 0,....,nothing) -----------------------------------
cs--------------------------------- someMethod(null,0,...., null); //this does not work!!! -----------------------------------
Seams easy enough, right?... but replacing that "nothing" with "null" doesn't work due to the argument being of a reference type.
Does that mean I would have to define, and initiaize the arguments? I know if I redefine the function in cs to use an "out" instead of a "ref" var, that I would not have to initialize the referenced variable.... but doesnt that mean I would still have to define a variable?
Any suggestions as to the fastest and cleanest way of getting the proper syntext for cs would be greatly appreciated. (example??)
thanks jamie .
Arguments passed to "ref" parameters must be variables in C#. VB actually
does this behind th scenes to hide this from you.
Similarly for "out" parameters - the arguments must be passed as variables.
BTW: "ref" is unrelated to "reference type". Either reference types or value
types can be passed "ref" or not.
David Anton www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter and the Instant VB C# to
VB.NET converter
"jamie" wrote: Yello, I am having a hard time converting from vb to cs. I think that vb as doing a little more behind the scenes, than I relized...
The prob code: vb--------------------------------- someMethod(nothing, 0,....,nothing) -----------------------------------
cs--------------------------------- someMethod(null,0,...., null); //this does not work!!! -----------------------------------
Seams easy enough, right?... but replacing that "nothing" with "null" doesn't work due to the argument being of a reference type.
Does that mean I would have to define, and initiaize the arguments? I know if I redefine the function in cs to use an "out" instead of a "ref" var, that I would not have to initialize the referenced variable.... but doesnt that mean I would still have to define a variable?
Any suggestions as to the fastest and cleanest way of getting the proper syntext for cs would be greatly appreciated. (example??)
thanks jamie .. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Johan Holst Nielsen |
last post by:
Hi all,
I hope someone can help me.
I have do do a color conversion from RGB to CMYK. It's harder than I
thought :D Anyway, here is my problem.
I tried some differents ways to do it - I...
|
by: Stub |
last post by:
Docs says that "The compiler does not use an explicit constructor to
implement an implied conversion of types. It's purpose is reserved
explicitly for construction."
I put up code of three cases...
|
by: Steve Gough |
last post by:
Could anyone please help me to understand what is happening here? The
commented line produces an error, which is what I expected given that
there is no conversion defined from type double to type...
|
by: nan |
last post by:
Hi All,
I am trying to connect the Database which is installed in AS400
using DB2 Client Version 8 in Windows box.
First i created the Catalog,
then when i selected the connection type...
|
by: riya1012 |
last post by:
hello guys,
I need some help from you. I am doing a DSP project and for that I need
to do some C coding for the conversion of sample data which is in
floating point representation to fixed point...
|
by: Richard G. Riley |
last post by:
Would it be wrong to use "implicit casting" instead of the standards
"implicit conversion" when talking about implicit conversions between
certain data types. The standard mentions "explicit...
|
by: Coleen |
last post by:
Hi All :-)
I'm new to this site. I've been trying to convert several .Net 2003 web applications and getting tons of conversion errors.
I found this site to help walk me through the...
|
by: somenath |
last post by:
Hi All,
I am trying to undestand "Type Conversions" from K&R book.I am not
able to understand the
bellow mentioned text
"Conversion rules are more complicated when unsigned operands are...
|
by: Ivan Velev |
last post by:
Hello,
Minimal example below - it gives me different output if I comment /
uncomment the extra time.mktime call - note that this call is not
related in any way to main logic flow.
When...
|
by: dataentryoffshore |
last post by:
Get a Discount up to 60% on data entry, data capture, dataentry
services, large volume data processing and data conversion services
through offshore facilities in India. Offshore data entry also...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |