Tejashri Patange
Tejashri Patange

Reputation: 339

% cannot be assigned to decimal type C#

I have a data type of type decimal.

I want to carry out following:

 if(decimalData % 0.25 !=0)
 {
     //do some manipulation
 }

But it is giving me the above error.

Upvotes: 0

Views: 38

Answers (1)

Anu Viswan
Anu Viswan

Reputation: 18153

Following should help you with decimal.

if(decimalData % 0.25M !=0)
{
 //do some manipulation
}

A "real literal" without suffix or with the d or D suffix is of type double. You could read more on suffix here

  • Suffix for Decimal - M or m
  • Suffix for float - F or f
  • Suffix for Double - Without any suffix or D/d

Upvotes: 2

Related Questions