Below is a code snippet to demonstrate how to Convert or cast integer to double in C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { internal class Program { private static void Main(string[] args) { double Input; int Output; Input = 25; // Abundant code - casts from double to int . This will result in loss of data Output = (int)(Input / 3); Console.WriteLine("Casting integer to double in C# result = " + Output); Console.ReadLine(); } } }
Leave a Reply