一、简述编写c#程序的步骤
每个程序都需要一个入口点,即程序开始执行的地方。在c#中,入口点就是main()方法。每个c#应用程序必须至少定义一个main()方法。定义多个main()方法也是可以的,但必须使用/main编译选项指定哪个main()方法是入口点。main()方法在创建任何类或结构的实例前被调用,因此它必须声明为static。下面是main()方法可以接受的方法签名。
public static void main()
public static int main()
public static void main(string[] args)
public static int main(string[] args)
最后两种形式用来向main()方法传递命令行参数,任何参数都被作为string类型的数组传递。方法的返回类型必须是void或int;返回值表示程序结束方式的约定,如返回值为0表示程序正常退出,非0的返回值表明程序出现了错误。
二、求c#入门教程
c#是一个纯面向对象的语言,尽管是可视化的编程工具,但我认为对零基础的初学者来说还是有点难度的,一般来说都是从学c语言开始,在没有老师的指导下学c也不简单啊,所以呢,学vb吧,简单易懂,可视化工具,一两星期就能上手的;
还有一个方法是从网上找一些c#视频看看,边看边学,
附:高中学这个,有点前卫哦,不过在国外的教育中,高中就把计算机基础的东西学完了,比如:编程、数电模电,等等。他人高中毕业对于编程,他们已经懂了,可是在中国,高中都在忙着考大学;
祝你好运!
三、一个c#的简单程序代码怎么写?
using system;
using system.collections.generic;
using system.linq;
using system.text;
namespace _2round
{
class program
{
static void main(string[] args)
{
try
{
point center = inputpoint("圆心");
console.writeline("请输入圆的半径:");
int r = int.parse(console.readline());
round c = new round() { r = r, center = center };
point otherpoint = inputpoint("另一个点");
console.writeline(c);
console.writeline("另一个点在圆的:{0}",c.compare(otherpoint));
}
catch (exception ex)
{
console.writeline(ex.message);
}
}
static point inputpoint(string pointname)
{
point result = new point() ;
try
{
console.writeline("请输入{0}的x:",pointname);
result.x = int.parse(console.readline());
console.writeline("请输入{1}的y:", pointname);
result.y = int.parse(console.readline());
}
catch
{
throw;
}
return result;
}
//static void run(int x1,int y1,int r,int x2,int y2)
//{
//}
}
public class round
{
public point center { get; set; }
//public int r { get; set; }
private int _r = 0;
public int r
{
get { return _r; }
set {
if (value <0)
{
throw new exception("半径不能小于0");
}
_r = value;
}
}
public double area
{
get
{
return math.pi * math.pow(this._r, 2);
}
}
public position compare(point otherpoint)
{
position result = position.outof;
double distance = 0;
distance = this.caldistance(otherpoint);
if (this._r>distance)
{
result = position.in;
}
else if (this._r == distance)
{
result = position.on;
}
return result;
}
private double caldistance(point otherpoint)
{
double result = 0;
result = math.sqrt(
math.pow(this.center.x-otherpoint.x,2)
+
math.pow(this.center.y - otherpoint.y, 2)
);
return result;
}
public override string tostring()
{
return string.format("圆心:{0},半径:{1},面积:{2}", this.center, this._r, this.area);
}
}
public enum position
{
in,
on,
outof
}
public struct point
{
public int x;
public int y;
//public int z { get; set; }
public override string tostring()
{
return string.format("({0},{1})", this.x, this.y);
//return base.tostring();
}
}
}