Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

CLI Deal Or No Deal

3rd program I've ever made in the language after hello world and magic 8-ball.

Have I picked up any horrible habits in my learning process? How could i make the code shorter? I'm still learning the language so please feel free to tell me how shit I am so I can improve :)

http://pastebin.com/hCw4N5d7

p.s. I know the algorithm to get the banker's offer is retarded and incorrect.
Why are you prefixing things with an underscore?
(Aug 10, 2013 10:38 PM)Xori Wrote:  Why are you prefixing things with an underscore?

to help me visually distinguish them from strings
Thank you for your wise words dreamer :)
(Aug 11, 2013 03:36 AM)dreamer66 Wrote:  Option A
Code
_CaseDisplayRep = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"," 14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26" };

Option B
Code
_CaseDisplayRep = new string[26];
for (int i = 0; i < _CaseDisplayRep.Length; i++)
{
    _CaseDisplayRep[i] = (i+1).ToString();
}

I could have probably found more things if I actually read the code, but these should get you to the right path. Good luck.

My Option - C
Code
int[] numbers = Enumerable.Range(1, 26).Select(i => i).ToArray();

OP This way is the cleanest way, but also the hardest to understand. Its Linq.


Possibly Related Threads...
Thread / Author Replies Views Last Post
by HackersNov 11, 2025 09:42 AM 0 206 Nov 11, 2025 09:42 AM
Last Post: Hackers
by HackersDec 11, 2024 05:11 PM 21 535 Dec 11, 2024 05:11 PM
Last Post: padrino
by HackersDec 11, 2024 08:31 AM 23 695 Dec 11, 2024 08:31 AM
Last Post: Hackers