using System;
public class SquareSample
{
public int CalcSquare(int nSideLength)
{
return nSideLength*nSideLength;
}
}
class SquareApp
{
 public static void Main()
{
SquareSample sq = new SquareSample();
Console.WriteLine(sq.CalcSquare(25).ToString());
有些地方不是太明白帮解释一下

解决方案 »

  1.   

    using System;       //导入命名空间
    public class SquareSample       //定义类
    {
      public int CalcSquare(int nSideLength)       //定义函数
      {
        return nSideLength*nSideLength;       //计算输入参数的平方,并返回
      }
    }
    class SquareApp       //定义类
    {
      public static void Main()       //程序入口,从这里向下执行
      {
        SquareSample sq = new SquareSample();   //定义一个SquareSample的实例sq
        Console.WriteLine(sq.CalcSquare(25).ToString());  //调用sq的CalcSquare计算25平方,并输出
      }
    }