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

C#

 
GeneralRe: Beginner in need of help Pin
Not Active23-Oct-09 7:02
mentorNot Active23-Oct-09 7:02 
GeneralRe: Beginner in need of help Pin
ely_bob23-Oct-09 7:41
professionalely_bob23-Oct-09 7:41 
GeneralRe: Beginner in need of help Pin
Not Active23-Oct-09 7:53
mentorNot Active23-Oct-09 7:53 
GeneralRe: Beginner in need of help Pin
ely_bob23-Oct-09 8:12
professionalely_bob23-Oct-09 8:12 
GeneralRe: Beginner in need of help Pin
Not Active23-Oct-09 8:22
mentorNot Active23-Oct-09 8:22 
GeneralRe: Beginner in need of help Pin
ragnaroknrol23-Oct-09 8:41
ragnaroknrol23-Oct-09 8:41 
GeneralRe: Beginner in need of help Pin
EliottA23-Oct-09 17:19
EliottA23-Oct-09 17:19 
GeneralRe: Beginner in need of help Pin
ragnaroknrol23-Oct-09 8:13
ragnaroknrol23-Oct-09 8:13 
The original statement said the program was making random scores for the games.

How would YOU propose the user get the random number from the program in order to input it in a text box that would then be converted to an int to be used by the program?

I don't understand why he would have made it a text string in the first place either. The best answer to the question is to fix the logic behind the decisions. I'm a novice programmer and I would have doen the same thing at first. I read some articles here and some books and I am figuring out that the most elegant code is the one that uses the least amount of convoluted conversions.

Would you make an int value convert to string, export it to XML, read it in a different spot in the program and then convert it to an int to be used in a math equation? Or would you just have the original number be used in the math problem directly?

Step 1: Make a random number generator.

private int RandomScore()
{
    Random randomNumbers = new Random();

    int randomScore1, randomScore2;

    for (int nmbr = 1; nmbr<55; nmbr++)
    {
        randomScore1 = randomNumbers.Next(1, 100);
        randomScore2 = randomNumbers.Next(1, 100);
    }
}


(and yes, I am aware it may not be a valid score for American football. Changing values in there will get the results you want.)

Use this to get the input and you completely remove the need for string conversions.
After this you use code ely_bob used and you essentially have everything you need. No need to have the user generate a random score.
GeneralRe: Beginner in need of help Pin
Not Active23-Oct-09 8:29
mentorNot Active23-Oct-09 8:29 
GeneralRe: Beginner in need of help Pin
ely_bob23-Oct-09 8:42
professionalely_bob23-Oct-09 8:42 
GeneralRe: Beginner in need of help Pin
ely_bob23-Oct-09 8:31
professionalely_bob23-Oct-09 8:31 
GeneralRe: Beginner in need of help [modified] Pin
ragnaroknrol23-Oct-09 8:46
ragnaroknrol23-Oct-09 8:46 
GeneralRe: Beginner in need of help Pin
ely_bob23-Oct-09 9:06
professionalely_bob23-Oct-09 9:06 
GeneralRe: Beginner in need of help Pin
ragnaroknrol23-Oct-09 9:11
ragnaroknrol23-Oct-09 9:11 
AnswerRe: Beginner in need of help Pin
Not Active23-Oct-09 7:01
mentorNot Active23-Oct-09 7:01 
QuestionSorry - I remove this topic to WCF forum Pin
dataminers23-Oct-09 5:40
dataminers23-Oct-09 5:40 
AnswerRe: WCF - OperationContract Generic Argument Pin
Not Active23-Oct-09 5:54
mentorNot Active23-Oct-09 5:54 
AnswerRe: WCF - OperationContract Generic Argument Pin
dan!sh 23-Oct-09 6:02
professional dan!sh 23-Oct-09 6:02 
AnswerRe: Sorry - I remove this topic to WCF forum Pin
Not Active23-Oct-09 6:49
mentorNot Active23-Oct-09 6:49 
GeneralRe: Sorry - I remove this topic to WCF forum Pin
dataminers23-Oct-09 8:44
dataminers23-Oct-09 8:44 
GeneralRe: Sorry - I remove this topic to WCF forum Pin
Not Active23-Oct-09 10:13
mentorNot Active23-Oct-09 10:13 
GeneralRe: Sorry - I remove this topic to WCF forum Pin
dan!sh 23-Oct-09 9:31
professional dan!sh 23-Oct-09 9:31 
GeneralRe: Sorry - I remove this topic to WCF forum Pin
Not Active23-Oct-09 10:10
mentorNot Active23-Oct-09 10:10 
Questionc# - copying out a segment from a byte array Pin
Alan Kurlansky23-Oct-09 5:02
Alan Kurlansky23-Oct-09 5:02 
AnswerRe: c# - copying out a segment from a byte array Pin
Matt Meyer23-Oct-09 5:28
Matt Meyer23-Oct-09 5:28 

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.