Implicit Type Conversion

CSharp · Console

/Program.cs

using System;

public class Program
{
	public static void Main()
	{
		int i = 786;
		double d1 = i; // Implicit casting from int to double

		int i1 = 57;
		// automatic type conversion
		long l = i1;
		float f = l;
		
		char i2 = '0';
		int d2 = i2;

		
		Console.WriteLine($"d1 = {d1}"); // Print 786
		Console.WriteLine($"l = {l}"); // Print 57
		Console.WriteLine($"f = {f}"); // Print 57
		Console.WriteLine($"d2 = {d2}"); // Print 48
	}
}
;