private void Test()
{
float f = 3.51f;
switch ((int)(f * 100))
{
case 350:
break;
}
}
Friday, 26 January 2018
Why Switch not Use Float and Double Value in C#.
in: csharp
In this article, We will discuss about Why Switch not Use Float and Double Value in C#.
Switch not Use Float and Double Value because it's value is not fixed at a particular amount of time or we can say that it's value is not Precise.
But still if we Use Float and Double value in Switch then it Will Show you error and Which is Shown in below figure,
To Resolve the error We can Convert that float or double value into int and then the Switch Will Work Perfectly like this,
RELATED POSTS

Formatting of numbers by Trailing Zeros in C#.
In this article, We will discuss about How to add Trailing Zeros in a St ...

Null-Conditional Operator in C# 6.0
Null-Conditional Operator is a new Concept in C# 6.0 that is useful when ...
Get All Location Details Using IPAddress in C#.
This article will tell you about how to retrieve User Locations by passin ...

Difference between First() and FirstOrDefault() in C#.
In this article, We will discuss about What is the difference between Fi ...
-
This issue is Completely related to EntityFramework and this issue arises whenever you have installed EntityFramework in one project at th...
-
This is generally a Common Problem or the error could be like this, To Resolve this error, One Small Solution is Exists which is as b...
-
In this article, We will discuss What is the above Error and How to resolve this Error. Whenever, We are Restoring our database into A...
0 comments:
Post a Comment