I have to create a control that can manipulate each "digit" of an integer value ( from 0
to 999,999
).
I know how to "Get" a digit of the integer - just Mod/Div -
public class IntegerModel{
private int _value = 0;
private int _GetValue( int baseValue, int modBy, int divBy ) =>
( baseValue % modBy ) / divBy;
public int Value => _this.Value;
public One => {
get => this._GetValue( this.Value, 10, 1 );
set => Console.WriteLine( "What do I put here?" );
}
public Ten{
get => this._GetValue( this.Value, 100, 10 );
set => Console.WriteLine( "What do I put here?" );
}
}
The problem is that I don't know how to eloquently SET the digit value.
If I was working in Binary it would be as simple as using some bitwise operators ( it may still be but I don't know exactly how to do it ).
So, ideally, if I were to, using this class, do the following, I would get the given output.
IntegerModel Foo = new IntegerModel( );
Foo.One = 7;
Foo.Ten = 3;
Console.WriteLine( Foo.Value ); //Output should be 37
What would I need to put in the One
and Ten
property setters to be able to achieve the desired behavior?