这是我的代码:对象引用是非静态字段的要求。 。 。 。 ,错误
的目的是为了在2阵列添加两个大的数字,首先输入两个数字,然后swaping两者并添加它们,控制台 - 基于,
我是一个新手C#所以请解释记住我的代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Sum_Two_BIG_Numbes
{
public class matrix
{
public int[] c;
public void input(int[] a)
{
for (int i = 0; i < a.Length; i++)
{
a[i] = Convert.ToInt32(Console.ReadLine());
}
}
public void Jamk(int[] a, int[] b, int[] c)
{
for (int i = 0; i < a.Length; i++)
{
int temp = a[i] + b[i];
if ((temp < 10) && (c[i] != 1))
{
c[i] = c[i] + temp;
}
else
{
c[i] = c[i] + temp % 10;
c[i + 1] = c[i + 1] + temp/10;
}
}
}
public void swap(int[] a)
{
for (int i = 0; i < a.Length; i++)
{
a[i] = a[a.Length - i];
}
}
}
class Program
{
public void Main(string[] args)
{
int[] a = new matrix();
//int[] a = new int[30];
int[] b = new int[30];
int[] c = new int[30];
Console.WriteLine("Enter First Number : ");
matrix.input(a);
Console.ReadLine();
}
}
}
我得到这个错误“的对象Refrence需要选用是对于非静态字段。。”
使用读了哪条线中的代码显示的错误? – 2012-07-12 20:17:36
最简单的方法来改变这个并获得访问权限将是使用关键字“static”将公共静态方法更改为公共静态 – MethodMan 2012-07-12 20:20:18
可能的[非静态字段,方法或属性'WindowsApplication1.Form1。 setTextboxText(INT)](http://stackoverflow.com/questions/498400/an-object-reference-is-required-for-the-nonstatic-field-method-or-property-wi) – Spontifixus 2014-03-19 17:48:11