编写运行一个最最最简单的C#程序

bluestar 2001-04-18 05:45:00
小弟接触C#不过2天,开始也是一头雾水,现在雾水少了一点,知道如何编写一个最最最简单的C#程序。

打开你的写字板
输入
class HelloWorld
{
public static void Main()
{
System.Console.WriteLine("Hello World");
}
}

存盘为hello.cs

用FrameWork SDK开发包(现在提供下载比较多的.Net开发包)中的CSC.exe
在DOS命令行敲csc hello.cs
如果没有错误的话,就可以生成hello.exe文件,就可以使用了。

FrameWork SDK开发包还有界面编辑器,就象VB一样,既可以编写VB7的程序,也可以编写C#的程序。
开发包中有大量资料,只要多看看,你会明白不少C#的知识的。

让高手见笑了!

...全文
556 25 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
25 条回复
切换为时间正序
请发表友善的回复…
发表回复
bicom 2001-07-30
  • 打赏
  • 举报
回复
同感!!!
Go_Rush 2001-06-07
  • 打赏
  • 举报
回复
我是C#新手,向大家学习啦!!
AWP365 2001-06-02
  • 打赏
  • 举报
回复
to drunkard:那段代码很明白呀,有什么不懂的?
AWP365 2001-06-02
  • 打赏
  • 举报
回复
过几天我写一个windows界面的ADO看看
bluestar 2001-06-02
  • 打赏
  • 举报
回复
不过要SDK开发包
evogel 2001-06-01
  • 打赏
  • 举报
回复
微软老学人家的东东
bluestar 2001-06-01
  • 打赏
  • 举报
回复
回csst,可以
csst 2001-05-31
  • 打赏
  • 举报
回复
问个菜问题,c#编译的运行程序可以在未装vs7的系统中运行吗?
litangel 2001-05-28
  • 打赏
  • 举报
回复
freezwy(网络自由人) :
网上有的是呀,
freezwy 2001-05-13
  • 打赏
  • 举报
回复
我也想用,不知道哪儿有IE5.5呀?
970361 2001-05-13
  • 打赏
  • 举报
回复
怎么跟java很相识啊
drunkard 2001-05-12
  • 打赏
  • 举报
回复
主要是要变Windows下的GUI程序吧,哪位能给出清晰简单简洁的GUI代码示例?

最好有通过ADO操作数据库的功能。

C#的示例太差了!

比如:

// ADO\adosample.cs

using System;
using System.Data;
using System.Data.ADO;

public class MainClass
{
public static void Main ()
{
// set Access connection and select strings
string strAccessConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=BugTypes.MDB";
string strAccessSelect = "SELECT * FROM Categories";

//Create the dataset and add the Categories table to it
DataSet myDataSet = new DataSet();
myDataSet.Tables.Add("Categories");

// create my Access objects
ADOConnection myAccessConn = new ADOConnection(strAccessConn);
ADODataSetCommand myAccessDataSetCmd = new ADODataSetCommand();
myAccessDataSetCmd.SelectCommand = new ADOCommand(strAccessSelect,myAccessConn);

myAccessConn.Open();
try
{
myAccessDataSetCmd.FillDataSet(myDataSet,"Categories");
}
finally
{
myAccessConn.Close();
}

try
{
/* A dataSet can contain multiple tables,
so let's get them all into an array */
DataTable[] dta = myDataSet.Tables.All;
foreach (DataTable dt in dta)
{
Console.WriteLine("Found data table {0}", dt.TableName);
}

/* The next two lines show two different ways
you can get the count of tables in a dataset */
Console.WriteLine("{0} tables in data set", myDataSet.Tables.Count);
Console.WriteLine("{0} tables in data set", dta.Length);
/* The next several lines show how to get information
on a specific table by name from the dataset */
Console.WriteLine("{0} rows in Categories table", myDataSet.Tables["Categories"].Rows.Count);
/* The column info is automatically fetched from the
database, so we can read it here */
Console.WriteLine("{0} columns in Categories table", myDataSet.Tables["Categories"].Columns.Count);
DataColumn[] drc = myDataSet.Tables["Categories"].Columns.All;
int i = 0;
foreach (DataColumn dc in drc)
{
/* Print the column subscript, then the
column's name and its data type */
Console.WriteLine("Column name[{0}] is {1}, of type {2}",i++ , dc.ColumnName, dc.DataType);
}
DataRow[] dra = myDataSet.Tables["Categories"].Rows.All;
foreach (DataRow dr in dra)
{
/* Print the CategoryID as a subscript,
then the CategoryName */
Console.WriteLine("CategoryName[{0}] is {1}", dr[0], dr[1]);
}
}
catch (Exception e)
{
Console.WriteLine("Oooops. Caught an exception:\n{0}", e.Message);
}
}
}

这段ADO代码示例,是在控制台下运行不说,也并不容易读懂,我除了连接串“Provider=Microsoft.Jet.OLEDB.4.0;Data Source=BugTypes.MDB”还有SQL语句外,一看其他的头都大了!
drunkard 2001-05-12
  • 打赏
  • 举报
回复
这样的代码,论坛里的兄弟都试过吧!

using System;
class HelloCSharp
{
static void Main()
{
Console.WriteLine("Hello C# !");
Console.ReadLine();
}
}

多加一行Console.ReadLine(); 省得在控制台站不住,就象原先在C里用getchar();一样
nne998 2001-05-11
  • 打赏
  • 举报
回复
我讨厌 VS.net ,我只喜欢 VC
lml1233 2001-05-09
  • 打赏
  • 举报
回复
我喜欢表达简洁的东西
litangel 2001-05-09
  • 打赏
  • 举报
回复
onion(葱头) 
那你就买张visual.net吧。
onion 2001-04-22
  • 打赏
  • 举报
回复
谁会下载这么大的东西啊。我的细细的电话线是不行了。我哭
Ninputer 2001-04-22
  • 打赏
  • 举报
回复
等同VB程序,仅供参考:
Public Class HelloWorld
Public Shared Sub Main()
System.Console.WriteLine("Hello World")
End Sub
End Class
飞天神笔 2001-04-20
  • 打赏
  • 举报
回复
FrameWork SDK在哪能下载到?
ginkgoboy 2001-04-20
  • 打赏
  • 举报
回复
好象和JAVA差不多嘛
加载更多回复(5)

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧