这是小程序的源代码:
using System;
class A
{
public int x;
public void Main()
{
x=5;
Console.WriteLine("这是x的值{0}", x);
Console.WriteLine("这是this.x的值{0}", this.x);
}
}在sdk 通过csc ,通不过,显示:不包含适合于如
using System;
class A
{
public int x;
public void Main()
{
x=5;
Console.WriteLine("这是x的值{0}", x);
Console.WriteLine("这是this.x的值{0}", this.x);
}
}在sdk 通过csc ,通不过,显示:不包含适合于如
解决方案 »
- 一个“;”的为什么.
- 验证码的问题
- 两个表连接时如何去掉重复列?在线等!急
- 我把用户权限放进一个长度为50的字符串中,'0'表示无权,'1'表示只读,'3'表示有权,但在代码中我不懂怎样进行比较而返回true或false,请过来
- XP SP1 系统装不了 VS.NET 2005 BETA 2 ,那是不是也装不了 .NET Framework v2.0 呢?
- 用C#怎么做一个短信平台 啊呀 急!!!!!
- 怎样检测网络是否通畅?
- 文件上传出错,请高手指教!
- 我的C#程序有两个写代码的地方,之间有什么关系,我有一个小小的问题请救,详情请看(UP)也有分。。。。
- winform程序打包 安装程序后打开快捷方式有错误
- 请教下怎么在子窗口控制主窗口中的控件
- 急!关于lable在窗体上显示的问题!
class A
{
public static int x;
public static void Main()
{
x = 5;
Console.WriteLine("这是x的值{0}", x);
Console.WriteLine("这是this.x的值{0}", x);
}
}
{
...
}
里面不能用this 也不能用非静态变量, 非静态变量只能用局部的
using System;
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
class A
{
public int x = 5;
void yanshi ()
{
Console.WriteLine ("这是x的值{0}", x);
Console .WriteLine ("这是this.x的值{0}", this.x);
}
}
}
}
运行后提示:1、应输入}
2、应输入类型、明明空间定义文件或文件尾这应该如何改。
using System.Collections.Generic;
using System.Text; namespace ConsoleApplication1
{ class Program
{
static void Main(string[] args)
{
A a = new A();
a.yanshi();
}
} class A
{
public int x;
public void yanshi()
{
x = 5;
Console.WriteLine("这是x的值{0}", x);
Console.WriteLine("这是this.x的值{0}", this.x);
} }
}
2.你这里的this想代指的是什么,类A还是窗体类啊,这是控制台程序,没有窗体类啊,类A也不能这样表示的。
而且你的主函数里还定义了个新类,不能这样用的啊,综合上述你的提问,我想你想表达的意思应该是:
namespace 控制台简单小程序
{
class Program
{
public static int X = 10;
static void Main(string[] args)
{
A a = new A();
a.X = 5;
Console.WriteLine("这是x的值{0}", a.X);
Console.WriteLine("这是this.x的值{0}",X);
}
}
class A
{
private int x;
public int X
{
get { return x; }
set { x = value; }
}
}
}一个是本类的x,另一个是其他类的x。不知道我想的你的问题对不对了