tagged [implicit-conversion]
Why does a generic type constraint result in a no implicit reference conversion error?
Why does a generic type constraint result in a no implicit reference conversion error? I have created a couple of interfaces and generic classes for working with agenda appointments: ``` interface IAp...
- Modified
- 2 Jul at 20:26
Is there a way to do dynamic implicit type casting in C#?
Is there a way to do dynamic implicit type casting in C#? Given this class with an implicit cast operator: I can now do the fo
- Modified
- 25 Mar at 14:15
When should I define a (explicit or implicit) conversion operator in C#?
When should I define a (explicit or implicit) conversion operator in C#? A somewhat little-known feature of C# is the possibility to create implicit or explicit [user-defined type conversions](http://...
- Modified
- 6 Sep at 12:0
Implicit Conversion over a Collection
Implicit Conversion over a Collection I ran into a problem this week regarding implicit conversions in C# on collections. While this (using `implicit`) may not be our final approach, I wanted to at le...
- Modified
- 8 Jun at 23:40
Why does C# allow an *implicit* conversion from Long to Float, when this could lose precision?
Why does C# allow an *implicit* conversion from Long to Float, when this could lose precision? A similar question [Long in Float, why?](https://stackoverflow.com/questions/4352213/long-in-float-why) h...
- Modified
- 20 Jun at 09:12
Can/should I use implicit operator instead of overriding ToString?
Can/should I use implicit operator instead of overriding ToString? I have a class that I want to easily write out to strings (e.g. for logging purposes). Can I use the implicit operator to implicitly ...
- Modified
- 25 Oct at 02:39
Implicit conversion issue in a ternary condition
Implicit conversion issue in a ternary condition > [Conditional operator cannot cast implicitly?](https://stackoverflow.com/questions/2215745/conditional-operator-cannot-cast-implicitly) [Why does n...
- Modified
- 23 May at 12:32
Why/when is it important to specify an operator as explicit?
Why/when is it important to specify an operator as explicit? I've borrowed the code below from [another question](https://stackoverflow.com/a/7305947/93394) (slightly modified), to use in my code: ```...
- Modified
- 23 May at 12:25
Should implicit operators handle null?
Should implicit operators handle null? We've got a type which has an implicit string operator. It looks like this: ``` public class Foo { readonly string _value; Foo(string value) { _value =...
- Modified
- 7 Feb at 11:37
How do I perform explicit operation casting from reflection?
How do I perform explicit operation casting from reflection? I want to use reflection and do either an implicit or explicit coversion using reflection. Given I have defined Foo this way ``` public cla...
- Modified
- 8 Sep at 16:19
Interfaces, Inheritance, Implicit operators and type conversions, why is it this way?
Interfaces, Inheritance, Implicit operators and type conversions, why is it this way? I'm working with a class library called DDay ICal. It is a C# wrapper for the iCalendar System implemented in Outl...
- Modified
- 26 Aug at 12:48
Type-proofing primitive .NET value types via custom structs: Is it worth the effort?
Type-proofing primitive .NET value types via custom structs: Is it worth the effort? I'm toying with the idea of making primitive .NET value types more type-safe and more "self-documenting" by wrappin...
- Modified
- 23 May at 11:54
What is the justification for this Nullable<T> behavior with implicit conversion operators
What is the justification for this Nullable behavior with implicit conversion operators I encountered some interesting behavior in the interaction between `Nullable` and implicit conversions. I found ...
- Modified
- 16 Apr at 23:35
Implicit conversion fails when changing struct to sealed class
Implicit conversion fails when changing struct to sealed class Struct/class in question: ``` public struct HttpMethod { public static readonly HttpMethod Get = new HttpMethod("GET"); public static...
- Modified
- 27 Mar at 10:44
Implicit conversion from char to single character string
Implicit conversion from char to single character string First of all: I know how to work around this issue. I'm not searching for a solution. I am interested in the reasoning behind the design choice...
- Modified
- 11 Sep at 17:34
Serious bugs with lifted/nullable conversions from int, allowing conversion from decimal
Serious bugs with lifted/nullable conversions from int, allowing conversion from decimal I think this question will bring me instant fame here on Stack Overflow. Suppose you have the following type: `...
- Modified
- 20 Aug at 18:55
Can I add an implicit conversion for two classes which I don't directly control?
Can I add an implicit conversion for two classes which I don't directly control? I'd like to be able to implicitly convert between two classes which are otherwise incompatible. One of the classes is `...
- Modified
- 2 Apr at 23:35