c# - What is the difference between explicit and implicit type casts? -
Would you please tell the difference between In an underlying cast, there is a clear context-protection conversion between the two: The compiler can prove that this static analysis ( With a clear artist, either you are saying the compiler that you know more than - "Please believe me, but Check anyway ": Although this artist is possible , then the compiler will not accept that all In an inherent primitive conversion (provided by language spec), it is generally assumed that a safe, non-risky, non-loss (warning: see John's comment ) Conversion: With a clear primitive conversion, it is possible that the conversion data may be lost, or it is unclear: With the Ospec Operator, all the bets are off, and you have to see the documentation. This can be a reference-cast, or it may anything adhere to the same rules as primitive conversions (example: Both of these custom-code code are context-specific. clear
and underlying
type Can you? This is a bit tricky because the "cast" syntax in C # is actually
list From & lt; Integer & gt; L = new list & lt; Int & gt; (); IList & LT; Integer & gt; IL = L;
list & lt; int & gt;
is always a IList & lt; int & gt;
from the list & lt; Integer & gt; L = new list & lt; Int & gt; (); IList & LT; Integer & gt; IL = L; & Lt; Integer & gt; L2 = (list & lt; int & gt;);
IList & lt; Int & gt;
In fact the list & lt; Int & gt;
- So let us tell it to tell it.
int i = 1; Float F = i;
Float F = 1; Int i = (int) f;
decimal
) or it's random Anything from:
XNamespace ns = "http: // abc / def"; // The built-in XAttribute attrib = GetAttrib (); Int i = (int) attrib; // clear (extract text from attrib value and parses for integer //)
Comments
Post a Comment