Why is f required while declaring floats in C#?


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);

Updated on: 23-Jun-2020

542 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements