第3题:using System.Windows.Forms; public class frmHelloApp : Form { public static void Main(string[] args) { //frmHelloApp frmhello=new frmHelloApp(); Application.Run(new frmHelloApp()); } public frmHelloApp() { }
}
to_hackbutter(火枪手) 难道书有错 ? 我看后面的 都是这样的? 咋办?
using System.Windows.Forms; public class frmHelloApp : Form { public static void Main(string[] args) { frmHelloApp frmhello=new frmHelloApp();
第一个问题: decimal w=3.145M; 注意后面的M 第二个问题: 你的问题是没有用namespace,你象我这样写就可以了 using System; using System.IO;class list { public static void Main(string[] args) { try {
int ctr=0; if (args.Length<=0) { Console.WriteLine("format: list filename"); return; } else { System.IO.FileStream f = new FileStream(args[0],FileMode.Open); try { StreamReader t=new StreamReader(f); string line; while ((line=t.ReadLine())!=null) { ctr++; Console.WriteLine("{0}:{1}",ctr,line); } f.Close(); } finally { f.Close(); } } } catch (System.IO.FileNotFoundException) { Console.WriteLine("list could not find the file {0}",args[0]); } catch (Exception e) { Console.WriteLine("exception:{0}\n\n",e); } } } 第三个问题: Application.Run(new frmCsTest()); 就可以了
TO_leonXXX(飞) 你说的第三题 和我一样 ??
sangengyi(三更呓) 这人挺坏的.
TO_ omafox() 说一个理由!
frmHello和frmhello怎么会一样,你笔误了吧?
对不起,没看清楚。 double类型的值不能隐含转换为decimal类型。 应该为: decimal w = 3.145m; 或为: decimal w = ( decimal )3.145;
public class frmHelloApp : Form
{
public static void Main(string[] args)
{
//frmHelloApp frmhello=new frmHelloApp();
Application.Run(new frmHelloApp());
}
public frmHelloApp()
{
}
}
?
我看后面的 都是这样的? 咋办?
public class frmHelloApp : Form
{
public static void Main(string[] args)
{
frmHelloApp frmhello=new frmHelloApp();
Application.Run(frmhello);
}
}
这样也行!
你用什么编译的?
问题二:改为public static void Main(string[] args)
问题三: frmHelloApp frmhello=new frmHelloApp();
Application.Run(frmhello);
shuicanyi (水残一),对么?
using System;
using System.IO;class list
{
public static void Main()
{
string[] args= new string[]{"file.txt"}; // 这句是我加的,因为原题内未定义 try
{
int ctr=0;
if (args.Length<=0)
{
Console.WriteLine("format: list filename");
return;
}
else
{
System.IO.FileStream f = new FileStream(args[0],FileMode.Open); //前面强制指定引用
try
{
StreamReader t=new StreamReader(f);
string line;
while ((line=t.ReadLine())!=null)
{
ctr++;
Console.WriteLine("{0}:{1}",ctr,line);
}
f.Close();
}
finally
{
f.Close();
}
}
}
catch (System.IO.FileNotFoundException)
{
Console.WriteLine("list could not find the file {0}",args[0]);
}
catch (Exception e)
{
Console.WriteLine("exception:{0}\n\n",e);
}
}
}
只知道 用CSC 本帖子 我加 40分 没有部分 ,我分很少了
我没有看懂后面的意思?
decimal w=3.145M;
注意后面的M
第二个问题:
你的问题是没有用namespace,你象我这样写就可以了
using System;
using System.IO;class list
{
public static void Main(string[] args)
{
try
{
int ctr=0;
if (args.Length<=0)
{
Console.WriteLine("format: list filename");
return;
}
else
{
System.IO.FileStream f = new FileStream(args[0],FileMode.Open);
try
{
StreamReader t=new StreamReader(f);
string line;
while ((line=t.ReadLine())!=null)
{
ctr++;
Console.WriteLine("{0}:{1}",ctr,line);
}
f.Close();
}
finally
{
f.Close();
}
}
}
catch (System.IO.FileNotFoundException)
{
Console.WriteLine("list could not find the file {0}",args[0]);
}
catch (Exception e)
{
Console.WriteLine("exception:{0}\n\n",e);
}
}
}
第三个问题:
Application.Run(new frmCsTest());
就可以了
你说的第三题
和我一样
??
这人挺坏的.
double类型的值不能隐含转换为decimal类型。
应该为:
decimal w = 3.145m;
或为:
decimal w = ( decimal )3.145;
谢谢 55555555555555555555555555
2.Main()方法应该加参数(string[] args)吧
3.按你的写法,应该是
frmHelloApp frmhello=new frmHelloApp();
Application.Run(frmHello);
中frmhello实例大小写问题或
同 epimetheus(阿戈尔) 说的:
用Application.Run(new frmHelloApp);即可
decimal myMoney = 300.5m;如果没有后缀 m,该数字将被视为 double,从而导致编译器错误。
2.static void Main(string[] args)3
Application.Run(frmhello);//h是小写,大写是类名了
新建一个ConsoleApplication就行了。一样好用的。