Yahoo Poland Wyszukiwanie w Internecie

Search results

  1. The value you have taken "1100.25" is actually decimal and not integer hence it can not be converted to long. You can use: String strValue = "1100.25"; decimal lValue = Convert.ToDecimal(strValue);

  2. 8 Answers. Sorted by: 257. Just do (int)myLongValue. It'll do exactly what you want (discarding MSBs and taking LSBs) in unchecked context (which is the compiler default). It'll throw OverflowException in checked context if the value doesn't fit in an int: int myIntValue = unchecked ( (int)myLongValue); edited May 13, 2009 at 16:36.

  3. 19 mar 2024 · A long can // hold any value an int can hold, and more! int num = 2147483647; long bigNum = num; For a complete list of all implicit numeric conversions, see the Implicit numeric conversions section of the Built-in numeric conversions article.

  4. Type casting is when you assign a value of one data type to another type. In C#, there are two types of casting: Implicit Casting (automatically) - converting a smaller type to a larger type size. char -> int -> long -> float -> double. Explicit Casting (manually) - converting a larger type to a smaller size type.

  5. Here’s a detailed overview of the various ways to convert data types in C#: 1. Implicit Conversion. Some types can be converted implicitly without needing explicit cast or conversion methods. This usually occurs when converting from a smaller type to a larger type (e.g., int to long). int myInt = 123; long myLong = myInt; // Implicit conversion.

  6. 14 wrz 2021 · Type conversion creates a value in a new type that is equivalent to the value of an old type, but does not necessarily preserve the identity (or exact value) of the original object. .NET automatically supports the following conversions: Conversion from a derived class to a base class.

  7. 7 lut 2024 · An implicit constant expression conversion permits the following conversions: A constant_expression (§12.23) of type int can be converted to type sbyte, byte, short, ushort, uint, or ulong, provided the value of the constant_expression is within the range of the destination type.

  1. Ludzie szukają również