C# code to triple a number
-
Hi, You can use the following classes
public class Single { private int _iValue; public int Value { get { return _iValue; } } public Single() : this(0) {} public Single(int iValue) { _iValue = iValue; } }; public class Double { private int _iValue; public int Value { get { Single sinA = new Single(_iValue); Single sinB = new Single(_iValue); return sinA.Value + sinB.Value; } } public Double() : this(0) {} public Double(int iValue) { _iValue = iValue; } }; public class Tripple { private int _iValue; public int Value { get { Double douA = new Double(_iValue); Single sinB = new Single(_iValue); return douA.Value + sinB.Value; } } public Tripple() : this(0) { } public Tripple(int iValue) { _iValue = iValue; } };
You can use it like this;
Tripple tripNumber = new Tripple(5); int iData = tripNumber.Value;
Learn from the mistakes of others, you may not live long enough to make them all yourself.
-
Hi, You can use the following classes
public class Single { private int _iValue; public int Value { get { return _iValue; } } public Single() : this(0) {} public Single(int iValue) { _iValue = iValue; } }; public class Double { private int _iValue; public int Value { get { Single sinA = new Single(_iValue); Single sinB = new Single(_iValue); return sinA.Value + sinB.Value; } } public Double() : this(0) {} public Double(int iValue) { _iValue = iValue; } }; public class Tripple { private int _iValue; public int Value { get { Double douA = new Double(_iValue); Single sinB = new Single(_iValue); return douA.Value + sinB.Value; } } public Tripple() : this(0) { } public Tripple(int iValue) { _iValue = iValue; } };
You can use it like this;
Tripple tripNumber = new Tripple(5); int iData = tripNumber.Value;
Learn from the mistakes of others, you may not live long enough to make them all yourself.
-
What about http://www.careerchange.com/[^]? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
J4amieC wrote:
Great answer, but you have too much time on your hands!
This is not correct. If I would have too much time on my hands I would have come with something Generic like this:
// Making it generic MultiType<Double, Double> mul4 = new MultiType<Double, Double>(5); int iData = mul4.Value; MultiType<Double, MultiType<Double, Single>> mul5 = new MultiType<Double, MultiType<Double, Single>>(5); iData = mul5.Value;
And the classes:
public class Single { protected int _iValue; public int Value { get { return Data(); } } public void setValue(int IValue) { _iValue = IValue; } protected virtual int Data() { return _iValue; } public Single() : this(0) {} public Single(int iValue) { _iValue = iValue; } }; public class Null : Single { public Null() : this(0) { } public Null(int iValue) { _iValue = 0; } protected override int Data() { return 0; } }; public class Double : Single { protected override int Data() { Single sinA = new Single(_iValue); Single sinB = new Single(_iValue); return sinA.Value + sinB.Value; } public Double() : this(0) {} public Double(int iValue) { _iValue = iValue; } }; public class MultiType<TL, TR> : Single where TL : Single, new() where TR : Single, new() { public MultiType() : this(0) { } public MultiType(int iValue) { _iValue = iValue; } protected override int Data() { Single baseLeft = new TL(); baseLeft.setValue(_iValue); Single baseRight = new TR(); baseRight.setValue(_iValue); return baseLeft.Value + baseRight.Value; } };
Learn from the mistakes of others, you may not live long enough to make them all yourself.
-
I myself made an assembly (TripleMachine.dll) that I just import whenever I need to triple a number. It has support for multithreading, for when I need to tripple large chunks of data.
boolean dontNotCancel = ((!false && true) != (!true || false)) ? ((false == false || (true && (false == true ? true : false))) ? true : false) : (true != false && false);
-
I myself made an assembly (TripleMachine.dll) that I just import whenever I need to triple a number. It has support for multithreading, for when I need to tripple large chunks of data.
boolean dontNotCancel = ((!false && true) != (!true || false)) ? ((false == false || (true && (false == true ? true : false))) ? true : false) : (true != false && false);
hey, looks like my signature o.o
betonglasermur.FeedDwarf(pur_is, 17);
ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);Morgonen är tröttmans mecka
-
hey, looks like my signature o.o
betonglasermur.FeedDwarf(pur_is, 17);
ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);Morgonen är tröttmans mecka
-
hey, that does not look like it isn't my signature
boolean dontNotCancel = ((!false && true) != (!true || false)) ? ((false == false || (true && (false == true ? true : false))) ? true : false) : (true != false && false);
hey, that aint not no signature :confused::confused::confused:
betonglasermur.FeedDwarf(pur_is, 17);
ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);Morgonen är tröttmans mecka
-
J4amieC wrote:
Great answer, but you have too much time on your hands!
This is not correct. If I would have too much time on my hands I would have come with something Generic like this:
// Making it generic MultiType<Double, Double> mul4 = new MultiType<Double, Double>(5); int iData = mul4.Value; MultiType<Double, MultiType<Double, Single>> mul5 = new MultiType<Double, MultiType<Double, Single>>(5); iData = mul5.Value;
And the classes:
public class Single { protected int _iValue; public int Value { get { return Data(); } } public void setValue(int IValue) { _iValue = IValue; } protected virtual int Data() { return _iValue; } public Single() : this(0) {} public Single(int iValue) { _iValue = iValue; } }; public class Null : Single { public Null() : this(0) { } public Null(int iValue) { _iValue = 0; } protected override int Data() { return 0; } }; public class Double : Single { protected override int Data() { Single sinA = new Single(_iValue); Single sinB = new Single(_iValue); return sinA.Value + sinB.Value; } public Double() : this(0) {} public Double(int iValue) { _iValue = iValue; } }; public class MultiType<TL, TR> : Single where TL : Single, new() where TR : Single, new() { public MultiType() : this(0) { } public MultiType(int iValue) { _iValue = iValue; } protected override int Data() { Single baseLeft = new TL(); baseLeft.setValue(_iValue); Single baseRight = new TR(); baseRight.setValue(_iValue); return baseLeft.Value + baseRight.Value; } };
Learn from the mistakes of others, you may not live long enough to make them all yourself.