This is a console application which can take in a number of relevant arguments and appropriately return the percentages and amounts of student loan repayments that would be deducted from a given wage. I've been getting into C# and wanted something to do that I could experiment with the basics on, so here we are. There's definitely a lot to tidy or improve - suggestions and notes welcome - but this was a fun first exercise, and I'm excited to build more things in the language!
Huge caveat on content that the UK student loan system is dark magic, subject to regular change, and none of this in any way constitutes mathematically or programmatically sound financial advice.
-
When declaring variables in cases for a switch case, single speech marks are what will cast a number to
chartype. Ie.case '1'will look forcharinput of1whereascase 1would look for anintandcase "1"would look for a string. -
Keeping with switch cases, didn't realise you could assign more than one case to an outcome. Eg:
switch (example)
{
case "1":
case "one":
// Code to be performed here.
}-
Particularly for past and probably future me: when using a text file for resources, if you can't seem to actually use the resources, even though you've definitely put them in the file, it's probably not massive machine error, and probably just that you forgot to run
resgen filename.txtafter adding new content to the text file. -
Useful pages for this, that might be useful later too and that I am bookmarking here, included:
- These government pages on what you pay and which repayment plan you are on if you're on one of the current UK student loan repayment plans.
- Also, the .NET documentation, but particularly this page on creating resource files for .NET apps, this page on the Console class and available methods, this page on method parameters, this page on object initialisers, the style guide for coding conventions, this introduction to OOP in C#, this introduction to LINQ, and this page on the CultureInfo object which was a cool thing to find out about.