Why is f required while declaring floats in C#?

ProgrammingServer Side ProgrammingCsharp

The f is a lowercase suffix set while declaring a float. It tells the compiler that the literal is of a specific type.

Example

 Live Demo

using System.IO;
using System;
public class Program {
   public static void Main() {
      float val = 30.22f;
      Console.WriteLine(val);
   }
}

Output

30.22

Above, we have set the float using f suffix.

IEnumerable res = val1.AsQueryable().Intersect(val2);
raja
Published on 11-Sep-2018 12:57:38
Advertisements