MOD operator

Hi All,
I Want to find the last digit of a 9 digit number for which I am using MOD operator but when I am giving the below condition it throws an error saying opeator MOD is not defined for Generic and Integer .
a= AccNum MOD 10

Both a and AccNum are Generic type

Hi @Rahul_Rama

You can handle this in two different ways.

  1. Change the data types of the two variables to integer
  2. Parse the value of the AccNum as integer in the code you check the MOD

A = Int32.Parse(AccNum)


@Lahiru.Fernando. It worked :slight_smile:
But what was wrong with Generic type ?

1 Like

Nothing is wrong with generic type :slight_smile: . Only thing is you need to specifically change it to integer when working with MOD operator. I know, you can always argue generic type should work with any data type as it automatically adjust itself. However, that’s not really the case with MOD :slight_smile:

If my fix worked, please also mark my answer as the solution too :slight_smile:


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.