Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3274638
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:03:37+00:00 2026-05-17T19:03:37+00:00

Below is draft number 5 for my C# Homework this week. I wrote the

  • 0

Below is draft number 5 for my C# Homework this week. I wrote the program out using Linq first, and it worked fine. Unfortunately, the directions state that I must create my own method instead of using the wonderful Sum() method already found in Linq. The major problem with this source code is that the method overload is incorrect (and it’s also probable that my entire Sum() method is wrong too). Since our almighty text doesn’t clearly explain how to overload a method like this, I’m kind of lost… (or a lot lost).

Here are the assignment instructions (again):

“Create a method named Sum()that accepts any number of integer parameters and displays their sum. Write a Main()method that demonstrates the Sum()method works correctly when passed one, three, five, or an array of 10 integers. Save the program as UsingSum.cs.”

from Microsoft® Visual C#® 2008, An Introduction to Object-Oriented Programming, 3e, Joyce Farrell

Here is my source code:

using System;

public class UsingSum
{
    public static void Main()
    {

        //Step 1: Adding 1, 3 and 5

        int[] array1 = { 1, 3, 5 };

        int a;
        int b;
        int c;
        int d;
        int e;
        int f;
        int g;
        int h;
        int i;
        int j;        
        int firstSum;
        int secondSum;

        Console.Write("When the numbers 1, 3 and 5 are added together, using the Sum() method, the answer is: ");

        firstSum = Sum(array1);
        Console.WriteLine("{0}", firstSum);



        //Step 2: Entering variables into Array2[10]


        Console.Write("Enter first integer for addition: ");
        a = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter second integer for addition: ");
        b = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter third integer for addition: ");
        c = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter forth integer for addition: ");
        d = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter fifth integer for addition: ");
        e = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter sixth integer for addition: ");
        f = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter seventh integer for addition: ");
        g = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter eighth integer for addition: ");
        h = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter ninth integer for addition: ");
        i = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter tenth integer for addition: ");
        j = Convert.ToInt32(Console.ReadLine());

        int[] array2 = { a, b, c, d, e, f, g, h, i, j };

        Console.Write("The total of {0} + {1} + {2} + {3} + {4} + {5} + {6} + {7} + {8} + {9} is: ",
        a, b, c, d, e, f, g, h, i, j);

        secondSum = Sum(array2);
        Console.WriteLine("{0}", secondSum);


    }


//Step 3: Defining the Sum() method

   public static int Sum(int a, int b)

//My overload is generating error CS1501: No overload for method 'Sum' takes '1' arguments

   {

   int sum = 0;
   int[] adder = new int[0];
//designating an array with no parameters...

   for(int a = 0; a < adder.Length; ++a)
      adder[a] = a;

   foreach(int b in adder)
      sum += b;
      Console.WriteLine(" " + sum);
   }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:03:37+00:00Added an answer on May 17, 2026 at 7:03 pm

    You are defining Sum to take 2 arguments

    public static int Sum(int a, int b)
    

    but only calling it with 1 argument

    firstSum = Sum(array1);
    

    Try defining Sum to take an int array:

    public static int Sum(int[] input)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below are two ways of reading in the commandline parameters. The first is the
Below is my current char* to hex string function. I wrote it as an
I am using the code below to save and restore the window position and
I have a small Bidding system that I'm using for a fantasy auction draft.
Below I have a very simple example of what I'm trying to do. I
Below is part of the XML which I am processing with PHP's XSLTProcessor :
Below is my $.ajax call, how do I put a selects (multiple) selected values
Below is the code of a simple html with a table layout. In FF
Below are lines from the c++ programming language template<class T > T sqrt(T );
Below is my (simplified) schema (in MySQL ver. 5.0.51b) and my strategy for updating

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.