params parameter
C#
2
Posts
1
Posters
0
Views
1
Watching
-
I have two functions:
void foo(params someRefObject[] arr);
andvoid foo(someRefType o);
When I callfoo(someRefInstance)
, which of them will be called? And what aboutfoo(null)
? Thanks. -
I have two functions:
void foo(params someRefObject[] arr);
andvoid foo(someRefType o);
When I callfoo(someRefInstance)
, which of them will be called? And what aboutfoo(null)
? Thanks.I did some checks, and I got the following:
foo(null)
won't compile, butfoo((someRefType)null)
, and foo(someRefInstance) will both callfoo(someRefType o)
. I wonder if it will be the same in the next version of .Net. Yaakov