Click here to Skip to main content
15,908,274 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# code to triple a number Pin
Xmen Real 8-May-08 2:32
professional Xmen Real 8-May-08 2:32 
AnswerRe: C# code to triple a number Pin
Christian Graus8-May-08 2:24
protectorChristian Graus8-May-08 2:24 
GeneralRe: C# code to triple a number Pin
dan!sh 8-May-08 2:28
professional dan!sh 8-May-08 2:28 
AnswerRe: C# code to triple a number Pin
Pete O'Hanlon8-May-08 2:26
mvePete O'Hanlon8-May-08 2:26 
AnswerRe: C# code to triple a number Pin
#realJSOP8-May-08 2:50
professional#realJSOP8-May-08 2:50 
AnswerRe: C# code to triple a number Pin
BadKarma8-May-08 2:51
BadKarma8-May-08 2:51 
GeneralRe: C# code to triple a number Pin
J4amieC8-May-08 3:00
J4amieC8-May-08 3:00 
GeneralRe: C# code to triple a number Pin
BadKarma8-May-08 4:26
BadKarma8-May-08 4:26 
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.

GeneralRe: C# code to triple a number Pin
J4amieC8-May-08 4:55
J4amieC8-May-08 4:55 
GeneralRe: C# code to triple a number Pin
BadKarma8-May-08 5:00
BadKarma8-May-08 5:00 
QuestionRe: C# code to triple a number Pin
CPallini8-May-08 3:20
mveCPallini8-May-08 3:20 
AnswerRe: C# code to triple a number Pin
Osten8-May-08 4:34
Osten8-May-08 4:34 
GeneralRe: C# code to triple a number Pin
laserbaronen8-May-08 4:36
laserbaronen8-May-08 4:36 
GeneralRe: C# code to triple a number Pin
Osten8-May-08 4:39
Osten8-May-08 4:39 
GeneralRe: C# code to triple a number Pin
laserbaronen8-May-08 4:41
laserbaronen8-May-08 4:41 
QuestionCMD.EXE from C# .net Pin
cristi_alonso8-May-08 1:34
cristi_alonso8-May-08 1:34 
AnswerRe: CMD.EXE from C# .net Pin
natsuyaki8-May-08 2:11
natsuyaki8-May-08 2:11 
QuestionmyProcess.StandardOutput Issue Pin
Harvey Saayman8-May-08 1:22
Harvey Saayman8-May-08 1:22 
AnswerRe: myProcess.StandardOutput Issue Pin
natsuyaki8-May-08 1:45
natsuyaki8-May-08 1:45 
QuestionPen Drive Pin
Bhim Prakash Singh8-May-08 0:53
Bhim Prakash Singh8-May-08 0:53 
AnswerRe: Pen Drive Pin
Christian Graus8-May-08 1:13
protectorChristian Graus8-May-08 1:13 
AnswerRe: Pen Drive Pin
Spunky Coder8-May-08 1:13
Spunky Coder8-May-08 1:13 
QuestionSending a E-mail in C# Pin
imnotso#8-May-08 0:21
imnotso#8-May-08 0:21 
AnswerRe: Sending a E-mail in C# Pin
N a v a n e e t h8-May-08 0:28
N a v a n e e t h8-May-08 0:28 
GeneralRe: Sending a E-mail in C# Pin
imnotso#8-May-08 0:47
imnotso#8-May-08 0:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.