-1

From excel i am getting number place value using mod operator like this =MOD(number,place*10) - MOD(number,place)

enter image description here

Please help how will i get like this in C#.

Rufus L
  • 36,127
  • 5
  • 30
  • 43
krishna
  • 23
  • 3
  • 9

1 Answers1

1

You can do the same in C#, just the syntax is different:

public int GetPlace(int value, int place)
{
    return (value % (place*10)) - (value % place);
}

See HERE for usage example.
If you just want the digit you can divide it by the place:

public int GetPlace(int value, int place)
{
    return ((value % (place * 10)) - (value % place)) / place;
}

see HERE

Christoph Fink
  • 22,727
  • 9
  • 68
  • 113
  • Thanks for reply, if value is 25000 it is not working, but i need number of hundreds from given value. plz assist – krishna Feb 01 '18 at 07:11
  • @krishna Sure it does - at least it does exactly what your example in Excel does (see updated snippet from the link)... – Christoph Fink Feb 01 '18 at 07:27