View Single Post
  #1 (permalink)  
Old March 11th, 2019, 01:14 AM
Eureka117 Eureka117 is offline
Registered User
Points: 23, Level: 1
Points: 23, Level: 1 Points: 23, Level: 1 Points: 23, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2017
Posts: 3
Thanks: 0
Thanked 2 Times in 1 Post
Default Chapter 26 Intro to LINQ

This issue is actually from beginning-microsoft-visual-c-2008-isbn-978-0-470-19135-4-400. I have that book and unfortunately the thread is closed there so I want to post my issue here so any others can benefit from a solution. Since this chapter is just the introduction to LINQ I don't think there will be too many differences from the code then (2008) as compared to now (2019).

On page 865, I typed the code exactly to create the generateLotsOfNumbers() function but receive this error when trying to compile:

Code:
'Program.generateLotsOfNumbers(int)': not all code paths return a value
I'm not at all sure what's going on as the book indicates there is nothing wrong with this code.

code:
Code:
private static int[] generateLotsOfNumbers(int count)
        {
            Random generator = new Random(0);
            int[] result = new int[count];
            
            for (int i = 0; i < count; i++)
            {
                result[i] = generator.Next();
            }
        }
Reply With Quote