KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Possible Duplicate: Why does params behave like this? If you write a method like this: void TestMethod(params object[] args) { } then if you call it like this: TestMethod() then the array will be empty. and if you call it like this: TestMethod(null, null) then the array will be an array with two null values. but why, when you call the method like this: TestMethod(null) will the array be null? I would have expected the result to be an array with one null value. I know about this C# - Is it possible to have null params? but does not explain why. --Edit: It's also interesting that TestMethod((object)null) is an array with one null value and TestMetod((object[])null) is a null array. It's just a case where being explicit in your intentions, by casting null to your expected type is the right way to go.
Tags (comma-separated)
Save Edits
Cancel