C# 非静态的字段、方法或属性“ConsoleApplication9.ad.SwaplfMax(int, int)”要求对象引用
什么意思?怎么改啊。using System;
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication9
{
class ad
{
public int a, b;
public void SwaplfMax(int a,int b)
{
int t;
if (a < b)
{
t = this.a;
this.a = this.b;
this.b = t;
}
}
static void Main(string[] args)
{
Console.WriteLine("请输入两个数");
ad max = new ad();
max.a = int.Parse(Console.ReadLine());
max.b = int.Parse(Console.ReadLine());
SwaplfMax(max.a,max.b);
Console.WriteLine("a={0},b={1}", max.a, max.b);
}
}
}
什么意思?怎么改啊。using System;
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication9
{
class ad
{
public int a, b;
public void SwaplfMax(int a,int b)
{
int t;
if (a < b)
{
t = this.a;
this.a = this.b;
this.b = t;
}
}
static void Main(string[] args)
{
Console.WriteLine("请输入两个数");
ad max = new ad();
max.a = int.Parse(Console.ReadLine());
max.b = int.Parse(Console.ReadLine());
SwaplfMax(max.a,max.b);
Console.WriteLine("a={0},b={1}", max.a, max.b);
}
}
}
解决方案 »
- 将string转换为System.Windows.FontStyle
- VS2008中 有时候一旦对控件的属性更改,整个界面会卡住 动不了 请问大家有什么解决办法吗
- 写配置文件问题
- 【请教】去掉string里面指定的字符?
- webservice 里面类型转换问题
- winform中datagrid前面的默认列怎么去掉?
- 谁有ActiveReport for net 的注册机 100 分赠
- 动态名字空间调用问题!
- win8.1下用visual studio 2012创建wp8应用程序,调试出错,提示错误 1 0x80131500
- 如何在C#中实现浮动的工具栏(就向VC6.0中的CToolBar一样)
- petshop4.0的解析中,下文是什么意思?
- 求:动态生成各种验证码的C#代码
SwaplfMax(max.a,max.b);
改为
max.SwaplfMax(max.a,max.b);
即可。
因为SwaplfMax()是对象的方法
不懂再说
改为:
public static void SwaplfMax(int a,int b)
SwaplfMax(max.a,max.b);
改为:
new ad().SwaplfMax(max.a,max.b);
也可以。