1

How do I do to improve my coding ability with VS2019 C# + winform.

 2 years ago
source link: https://www.codeproject.com/Questions/5317013/How-do-I-do-to-improve-my-coding-ability-with-VS20
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Example :
Copy Code
Input Two Any Value With Int Type, Call Them 'A', 'B'.
User Can Input A Positive Value For How Many Times The System Creates A Random Number 'M' , A <= M < B.
The System Will Create Random Number 'M' Between 'A' And 'B'.
The Winform Calculates Random Number's Result And Show Them Out.

Hi All, I Create A Bad Coding. Although It Can Work, But The Processing System Struct Was Horrible.
How Do I Do To Improve My Coding Ability. If Anyone Can Help And Give Me Some Suggestions Or Through Direction.
I Need To Fix My Code To More Clean, Readability.How I Start My Coding Let The Winform Become More Completely. Thanks Guys.

GitHub - worldpeaceend/RandomNumber: input two any value with int type, call them a, b.[^]

What I have tried:
Copy Code
The Exam Need To Use List<List<int>>, And Dictionary<int, int> To Finish. I Can Not Totally UnderStand How To Use 'Key' And 'Value' Of List And Dictionary.
At First, I Try To Use Array To Finish The System Function.
But The Winform Become More And More Terrible.
Comments
Why do you need a Dictionary? Create a simple List<int> to hold the random numbers as you generate them. You can then use that list to populate a ListBox on your form to display all the generated values.

Quote:

I Can Not Totally UnderStand How To Use 'Key' And 'Value' Of List And Dictionary.

Lists don't have "Key" or "Value" - dictionaries do because they store two bits of information: a Key which must be unique and a Value which is associated with that key.
For example, a Dictionary<int, Product> might use the ProductID as the Key and the Product itself as the Value: then you use it by supplying the ID Key and acess the Product from that:
Copy Code
string desc = products[prodID].Description;
int stockLevl = products[prodID].InStock;
A List doesn't do that: it just stores the Products and allows you to access them by index:
Copy Code
for (int i = 0; i < products.Count; i++)
   {
   Console.WriteLine($"{products[i].Description}: {products[i].Instock}");
   }


To be honest, if you don't understand the difference between a Dictionary and a List, then that probably explains why your code is low quality - you need to learn the basics and get them down pretty solidly before you start coding complicated apps.

We can't tell you how to improve code we haven't looked at - and I'm certainly not bouncing off to GitHub to look through a whole app to work out what you did so badly - so I'll just say it again: learn the basics well. Until they are instinctive, you can't build good code on top of them.

Add your solution here

Preview

Existing Members

Sign in to your account

...or Join us

Download, Vote, Comment, Publish.

Your Email   Password  

 

Your Email   Optional Password  

StrengthToo short

 

I have read and agree to the Terms of Service and Privacy Policy
Please subscribe me to the CodeProject newsletters
When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK