-5

Possible Duplicate:
Issue using switch case statement

I have code like this currently

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Drawing;
using System.ComponentModel;
using Excel = Microsoft.Office.Interop.Excel;
using Microsoft.Office.Interop.Excel;
namespace Excel1
{
    class Program
    {
        static void Main(string[] args)
        //public void ExcelOps()
        {
            //string str;
            Excel.Application xlApp = new Excel.Application();
            Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(@"D:/WebServiceTemplate.xlsx");
            Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
            Excel.Range xlRange = xlWorksheet.UsedRange;
            int rowCount = xlRange.Rows.Count;
            int colCount = xlRange.Columns.Count;
            int numSheets = xlWorkbook.Sheets.Count;
            //
            // Iterate through the sheets. They are indexed starting at 1.
            //
            for (int sheetNum = 1; sheetNum <=1; sheetNum++)
            {
                Worksheet sheet = (Worksheet)xlWorkbook.Sheets[sheetNum];
                //
                // Take the used range of the sheet. Finally, get an object array of all
                // of the cells in the sheet (their values). 
                //
                object[,] valueArray = (object[,])xlRange.get_Value(XlRangeValueDataType.xlRangeValueDefault);
                //
                // Do something with the data in the array with a custom method.
                //                
                ProcessInput(valueArray);
            }
        }
        public static void ProcessInput()
        {
        }
    }
}

I am trying to do something with the data in the array with a custom method. When I run it, I get an error "Error No overload for method 'ProcessInput' takes 1 arguments"

What is wrong? How do I go ahead and rectify this?

7
  • It means that the ProcessInput method is not visible from where you are calling it. Where is it defined? Commented Jun 15, 2012 at 7:59
  • Where is 'ProcessInput' defined? You are calling it as if it is a member method of your Program. Commented Jun 15, 2012 at 8:00
  • @O.R.Mapper Pls check the question now Commented Jun 15, 2012 at 8:03
  • @ebad86 Kindly check the question now... Commented Jun 15, 2012 at 8:04
  • Can you please create new questions for new problems, or edit your question in a way that your previous problems are not deleted? SO is meant as a permanent resource, and someone who visits this question tomorrow will not be able to figure out what most of our current answers refer to. Thank you. Commented Jun 15, 2012 at 8:10

3 Answers 3

8

if this is a complete code, the compiler is absolutely right.

You don't have any ProcessInput(..); function definition in this code.

EDIT

Looking on edited post would say that what you missed is declaring your ProcessInput functions like a static

    public static void ProcessInput()
    {
       ....
    }
Sign up to request clarification or add additional context in comments.

Comments

4

Now (after the edit to your question) the problem is that you are calling an instance method (ProcessInput) without having an instance of your class Program (Main is a static method).

Mark ProcessInput as static, too, to solve the problem:

public static void ProcessInput()
{
}

Alternatively, create an instance of your Program class and call the method on that:

Program prg = new Program();
prg.ProcessInput();

Comments

3

Try changing to

public static void ProcessInput()
{
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.