可能重复:
使用switch case语句发出问题
我目前有这样的代码
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()
{
}
}
}
Run Code Online (Sandbox Code Playgroud)
我试图用自定义方法对数组中的数据做一些事情.当我运行它时,我收到一个错误"错误没有重载方法'ProcessInput'需要1个参数"
怎么了?我该如何进行纠正?
如果这是一个完整的代码,编译器是绝对正确的.
您在此代码中没有任何 ProcessInput(..);函数定义.
编辑
查看编辑后的帖子会说你错过的是声明你的ProcessInput功能就像一个static
public static void ProcessInput()
{
....
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
214 次 |
| 最近记录: |