Click here to Skip to main content
15,887,350 members
Home / Discussions / C#
   

C#

 
AnswerRe: Track two types of values within one variable Pin
SledgeHammer0127-Jul-12 11:45
SledgeHammer0127-Jul-12 11:45 
GeneralRe: Track two types of values within one variable Pin
jschell27-Jul-12 11:57
jschell27-Jul-12 11:57 
GeneralRe: Track two types of values within one variable Pin
Paul Conrad28-Jul-12 9:31
professionalPaul Conrad28-Jul-12 9:31 
GeneralMessage Removed Pin
27-Jul-12 12:24
professionalN_tro_P27-Jul-12 12:24 
GeneralRe: Track two types of values within one variable Pin
SledgeHammer0127-Jul-12 12:36
SledgeHammer0127-Jul-12 12:36 
GeneralMessage Removed Pin
27-Jul-12 13:52
professionalN_tro_P27-Jul-12 13:52 
GeneralRe: Track two types of values within one variable Pin
jschell28-Jul-12 6:33
jschell28-Jul-12 6:33 
AnswerRe: Track two types of values within one variable Pin
Trak4Net27-Jul-12 18:26
Trak4Net27-Jul-12 18:26 
I would be more inclined to use the enum over abstract classes and interface for something like this. Unless there is a deeper level of programming that isn't being shown I would stick with simplicity.

This would be my interpetation of the object you are wanting also with a nice ToRateString() method so you can use the rate object to easily display your value in preformatted string.

C#
Rate r = new Rate(ENRateType.Dollar, 5.58d);
//r.ToRateString() would display $5.58


C#
public enum ENRateType { Dollar, Percent }

public class Rate
{
    public Rate()
    {
        RateType = ENRateType.Dollar;
        Value = 0d;
    }

    public Rate(ENRateType rateType, double value) : this()
    {
        RateType = rateType;
        Value = value;
    }

    public ENRateType RateType {get; internal set;}
    public double Value { get; internal set; }

    public string ToRateString()
    {
        if (RateType == ENRateType.Dollar) return "$" + Value.ToString("0.00");
        return Value.ToString("0.000") + "%";
    }

}

GeneralRe: Track two types of values within one variable Pin
Paul Conrad28-Jul-12 9:32
professionalPaul Conrad28-Jul-12 9:32 
AnswerRe: Track two types of values within one variable Pin
Northcodedotno29-Jul-12 8:36
Northcodedotno29-Jul-12 8:36 
AnswerRe: Track two types of values within one variable Pin
BobJanova29-Jul-12 23:16
BobJanova29-Jul-12 23:16 
GeneralAdding databound ComboBox into cells of a DataGridView Pin
Dewald27-Jul-12 2:11
Dewald27-Jul-12 2:11 
QuestionHow to make GRIDVIEW as Rounded Corners Pin
mukusingh27-Jul-12 0:33
mukusingh27-Jul-12 0:33 
AnswerRe: How to make GRIDVIEW as Rounded Corners Pin
Richard MacCutchan27-Jul-12 1:57
mveRichard MacCutchan27-Jul-12 1:57 
AnswerRe: How to make GRIDVIEW as Rounded Corners Pin
AmitGajjar27-Jul-12 17:54
professionalAmitGajjar27-Jul-12 17:54 
Questionrefresh result in MDI child Pin
Jassim Rahma27-Jul-12 0:05
Jassim Rahma27-Jul-12 0:05 
AnswerRe: refresh result in MDI child Pin
Eddy Vluggen27-Jul-12 0:09
professionalEddy Vluggen27-Jul-12 0:09 
GeneralRe: refresh result in MDI child Pin
Jassim Rahma27-Jul-12 0:28
Jassim Rahma27-Jul-12 0:28 
GeneralRe: refresh result in MDI child Pin
Eddy Vluggen27-Jul-12 0:47
professionalEddy Vluggen27-Jul-12 0:47 
GeneralRe: refresh result in MDI child Pin
Jassim Rahma27-Jul-12 2:52
Jassim Rahma27-Jul-12 2:52 
GeneralRe: refresh result in MDI child Pin
Eddy Vluggen27-Jul-12 2:59
professionalEddy Vluggen27-Jul-12 2:59 
QuestionHow can I attach wndproc to another window and do something when certain wm_event appears ? Pin
Member 964871826-Jul-12 23:57
Member 964871826-Jul-12 23:57 
AnswerRe: How can I attach wndproc to another window and do something when certain wm_event appears ? Pin
Eddy Vluggen27-Jul-12 0:52
professionalEddy Vluggen27-Jul-12 0:52 
GeneralRe: How can I attach wndproc to another window and do something when certain wm_event appears ? Pin
Member 964871827-Jul-12 1:54
Member 964871827-Jul-12 1:54 
GeneralRe: How can I attach wndproc to another window and do something when certain wm_event appears ? Pin
Eddy Vluggen27-Jul-12 1:59
professionalEddy Vluggen27-Jul-12 1:59 

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.