473,396 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Passing a Null to Web Method


1) Do c# web methods support default parameters ?
2) Can a web method, or a c# method such as:

public nullTest( int i )
{
return i++;
}

Can the web service consumer pass in a value of nullTest(null) ?
3) What if the web service is passing in a series of records where some
of the data for that parameter is null ? How should a null be passed
to the web service ?
--
incognito @ http://kentpsychedelic.blogspot.com
Nov 21 '05 #1
5 7346
1) No. See http://blogs.msdn.com/csharpfaq/arch.../07/85556.aspx for
more info.
2) No. Maybe in Framework 2.0 where nullable variables or how you call it,
are supported. If the parameter type is an object, you can of course, pass a
null value.
3) Not sure I understand what you mean :)
"J. L. Goddard" <jl@jl.NOSPAM> wrote in message
news:jL***************@newsread2.news.pas.earthlin k.net...

1) Do c# web methods support default parameters ?
2) Can a web method, or a c# method such as:

public nullTest( int i )
{
return i++;
}

Can the web service consumer pass in a value of nullTest(null) ?
3) What if the web service is passing in a series of records where some
of the data for that parameter is null ? How should a null be passed
to the web service ?
--
incognito @ http://kentpsychedelic.blogspot.com

Nov 21 '05 #2
Razzie wrote:

Thanks. That's a good blog.

Unfortunately for us web methods don't support overloading !

So for a consumer of a web service, he has to account for all parameters
with 'dummy data' I guess...

That means if his value is null, for an int, and he wants to pass a record
to me with a web service/method, he has to make up a value like 0, and use
that.

That's not good integrity.
1) No. See http://blogs.msdn.com/csharpfaq/arch.../07/85556.aspx
for more info.
2) No. Maybe in Framework 2.0 where nullable variables or how you call it,
are supported. If the parameter type is an object, you can of course, pass
a null value.
3) Not sure I understand what you mean :)
"J. L. Goddard" <jl@jl.NOSPAM> wrote in message
news:jL***************@newsread2.news.pas.earthlin k.net...

1) Do c# web methods support default parameters ?
2) Can a web method, or a c# method such as:

public nullTest( int i )
{
return i++;
}

Can the web service consumer pass in a value of nullTest(null) ?
3) What if the web service is passing in a series of records where some
of the data for that parameter is null ? How should a null be passed
to the web service ?
--
incognito @ http://kentpsychedelic.blogspot.com


--
http://kentpsychedelic.blogspot.com
Nov 21 '05 #3
Not sure I understand the question fully. But you could box the int in an
object and pass that or null ( I think ) or create a DBInt struct value type
like in Anders H. C# book (I just saw the code a bit.)

--
William Stacey, MVP

"J. L. Goddard" <jl@jl.NOSPAM> wrote in message
news:jL***************@newsread2.news.pas.earthlin k.net...

1) Do c# web methods support default parameters ?
2) Can a web method, or a c# method such as:

public nullTest( int i )
{
return i++;
}

Can the web service consumer pass in a value of nullTest(null) ?
3) What if the web service is passing in a series of records where some
of the data for that parameter is null ? How should a null be passed
to the web service ?
--
incognito @ http://kentpsychedelic.blogspot.com


Nov 21 '05 #4
William Stacey [MVP] wrote:
Not sure I understand the question fully. But you could box the int in an
object and pass that or null ( I think ) or create a DBInt struct value
type like in Anders H. C# book (I just saw the code a bit.)


So are you saying given:

public int NullTest(int i)
{
returns i++;
}

I could say:
object o = null; // box null into an object box
int value2 = (int) o; // unbox into value2
public int NullTest(value2); // ???

Or should I configure NullTest() like:

public int NullTest(obj o)
{
returns ((int) o) ++ ;
}

And call it with

object o = null;
int j = NullTest(o); // ???

Because a datatype o can be null, but a datatype int cannot accept a null
value when passed in as a parameter ?
--
http://kentpsychedelic.blogspot.com
Nov 21 '05 #5
Hi novelle.vague ( Maestro Bailo ),

You asked if nullTest() could call this:

nullTest( int i ) { return i ++ ; }

If it's like C++, the answer is no.

nullTest() with no parameters would give a compile-time error.

But, if " i " is a global, for example,
you could overload nullTest() like this:

nullTest() { return i ++ ; }

nullTest( int J ) { return i = ++ J ; }

Re: Your: nullTest( null ),

NULL is a macro in C++, it's defined as 0 ( Zero ).

Did you mean: nullTest( void ) ?

You asked: <<
3) What if the web service is passing in
a series of records where some
of the data for that parameter is null ?

How should a null be passed to the web service ? >>

Create overloaded functions ?

Re: http://kentpsychedelic.blogspot.com ,

Your blog really rocks. You're a genius Bailo.

But my FireFox .9 was caching it...
I wasn't seeing the latest version.
( I think I've fixed that now )

Did you have a stroke ?
Nov 21 '05 #6

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

Similar topics

5
by: Andy | last post by:
Hi Could someone clarify for me the method parameter passing concept? As I understand it, if you pass a variable without the "ref" syntax then it gets passed as a copy. If you pass a...
5
by: J. L. Goddard | last post by:
1) Do c# web methods support default parameters ? 2) Can a web method, or a c# method such as: public nullTest( int i ) { return i++; }
1
by: lolomgwtf | last post by:
I have a managed C++ method that wraps unmanaged code and creates a managed object holding data retrieved form an unmanged one. I want create an instance of this managed class in C#, pass it to...
3
by: No Spam Man | last post by:
I've got an app that I've written using C# and some type libraries I've generated from some of the directx .IDL files. I have got a problem with calling some of the methods on the generated...
8
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
7
by: TS | last post by:
I was under the assumption that if you pass an object as a param to a method and inside that method this object is changed, the object will stay changed when returned from the method because the...
3
by: DaTurk | last post by:
If I call this method, and pass it a byte by ref, and initialize another byte array, set the original equal to it, and then null the reference, why is the original byte array not null as well? I...
9
by: Chris | last post by:
Ok, so I have this sub I wrote, and I create a new instance of a UserControl: ctrlAPs tempctrl = new ctrlAPs(); Now, I would like to be able to use this sub I wrote for more than one...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.