求简单的C#代码

2025-06-21 20:07:27
推荐回答(5个)
回答1:

public class 车
{
private int 能源;
private int 轮子个数;
public int 承载能力;
public string 车牌;
public 车()
{
// 这是车的构造函数
}
public 车(int 轮子数)
{
this.轮子个数 = 轮子数;
}
}

强大的国际化,让变量也能使用中文。而且非常理性的面向对象编程。

回答2:

以下是A+B的例子,希望对你有帮助。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Plus
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please Enter A and B:");
int a, b;
Console.Write("A = ");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("B = ");
b = int.Parse(Console.ReadLine());

int c = a + b;
Console.WriteLine("{0} + {1} = {2}", a, b, c);
Console.ReadKey();
}
}
}

回答3:

楼主。。。 恐怕你C都没入门吧。。 不然怎么会C#的a+b或者hello world都写不出来呢。。。
建议不要频繁的换语言,不然你一觉得难就很容易放弃而去学其他语言了。a+b 或者 hello world这样的代码几乎每本书上都有,何必来这求呢。。
建议还是先把C学好。。
我做了半年的C#开发,现在还是要回过头来看C。

我没说学C#一定要先学C,但是你一上来就用C#里面那些封装好了的东西,你对C#本身的理解也会很有限。
C#里面连int等基本类型都是带方法的结构体,直接学C#真的是够呛。

回答4:

其实c#和c语言都差不多的,C#是继承了C++的一些优点,建议你先看一些简单关于C#的书籍,到你学会了你就觉得挺简单的,编程的思想都是一样的,只不过各门语言有点区别罢了。

回答5:

来个 Hello World

public class P
{
static void Main()
{
System.Console.WriteLine("HELLO WORLD");
}
}