tags:

views:

95

answers:

1

Hi, I've WebService written in Java that has method

@WebMethod    
public void createUser(Long id, String name)
{

}

Now I want to use this method in .NET client. I think I should be able to use this method with nullable long but I can't. Is there any annotation or maybe some other way to force .NET use nullable types?

I think that if in java I use Long (not long) so it's natural that in .NET I'll have method with nullable parameter

+1  A: 

In C#, nullable types use the '?' markup, so the datatype would be long?, or Nullable<Long>. If you need to get the actual long out of them, the best way to do it is NullableLong.Value

Thanks to Gratz' comment! What he means is, in a nullable type, you want to do NullableLong.HasValue, which returns a bool saying whether or not the variable is null.

Erich
You also might want to check .HasValue first
Gratzy