Let's say I wanted to create a constant that would return exchange fees for me as double
in C#. Here is what I would do in JavaScript:
var exchangeFees = {
fidelity: .25,
etrade: .2,
scottTrade: .15
}
This way, I can import this and have it work as a sort of enum: exchangeFees.fidelity
would get me the fee I need, and is clear. In Typescript, I would do something a bit less rational:
//I just realized this could just be a static class after I typed this
export class ExchangeFees {
FIDELITY: number;
ETRADE: number;
SCOTTTRADE: number;
constructor() {
this.FIDELITY= .25;
this.ETRADE= .2;
this.SCOTTTRADE = .15;
}
}
export const exchangeFees : ExchangeFees = new ExchangeFees ();
This seems hacky-as-hell, but Javascript, whatchu gonna do, etc. This just seems hacky in C# though, do I just create a static class and put it in a Constants.cs
file like so? Is there a better way?
public static class ExchangeFess
{
public static double Fidelity = .25;
public static double Etrade = .2;
public static double ScottTrade = .15;
}
I read the answer here, should I put it in AppSettings
somehow or is there no point?
I realize this is 101 question, but I am not sure I am approaching this cleanly.