Implicit cast converts null to object
See original GitHub issueIn ServiceOverride.cs L82 the implicit cast converts a ServiceOverride of null into an object. This took me a while to figure out because it is behavior I never saw before. Is this intended?
public static implicit operator Dependency(ServiceOverride item)
{
return new Dependency(item);
}
I would have expected the cast like this:
public static implicit operator Dependency(ServiceOverride item)
{
return item == null ? null : new Dependency(item);
}
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
c# - Implicit conversion from null
My question: It works fine, if I pass an actual object, mapping it to an Maybe, but if I pass NULL, I still...
Read more >Nullable<T>.Implicit(T to Nullable<T>) Operator (System)
In C# and Visual Basic, an implicit conversion from a null or Nothing literal to Nullable<T> produces a Nullable<T> value whose HasValue property...
Read more >C#: Implicit conversion from null to struct (and more)
When an implicit cast of null to the struct is required, having no other logical options, the compiler assumes that "null" is a...
Read more >Error in implicit conversion. Cannot convert null object - Help
Hi Developer, i found issue regarding write range activities. Write Range: Error in implicit conversion. Cannot convert null object
Read more >566 – Implicit Conversions to Nullable Types
A nullable type represents a type whose value can be either a particular value type or can be the null value. You can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am gonna do it tonight and open a PR. Alright?
Thanks. I will try if I am now able to work on the code. Would love to contribute.