J
james b
Hi all,
I'm trying to do something with method overloading and I can't seem to
get it to work
my code is along the lines of
public int method1(int a, int b, int c){
//method body
}
public int method1(int a, int b){
method1(a,b,null}
public int method1(int a){
method1(a,null,null)
}
I understand that int is a value type and so can't be null, but all
the examples i find using value types for overloading pass 0, which is
no good for me as this is a meaningful value for the parameter, i want
to pass something that says the parameter is empty. I have tried using
Int32 and this complains that it can't be null too.
I have considered creating my own object wrapping int just so i can
pass null, but that seems absurd. Is there an object (equivalent to
Java's Integer) that i have missed, or are you supposed to do
overloading in some different way in this situation?
many thanks
James
I'm trying to do something with method overloading and I can't seem to
get it to work
my code is along the lines of
public int method1(int a, int b, int c){
//method body
}
public int method1(int a, int b){
method1(a,b,null}
public int method1(int a){
method1(a,null,null)
}
I understand that int is a value type and so can't be null, but all
the examples i find using value types for overloading pass 0, which is
no good for me as this is a meaningful value for the parameter, i want
to pass something that says the parameter is empty. I have tried using
Int32 and this complains that it can't be null too.
I have considered creating my own object wrapping int just so i can
pass null, but that seems absurd. Is there an object (equivalent to
Java's Integer) that i have missed, or are you supposed to do
overloading in some different way in this situation?
many thanks
James