我就是不知道真正的C#规则是如何的,是先写方法,然后在Main()里面调用。。还是先在Main()里面把输出代码先写好然后在慢慢写方法。大家看这个例子,大家一定看的懂,我只是不懂的应该先从哪里下手写,希望大家指导一下我,谢谢!namespace konjian
{
class MainEntryPoint
{
public static void Main(string[] args)
{
Console.WriteLine("Pi is" + MathTest.GetPi());
int x = MathTest.GetSquareOf(5);
Console.WriteLine("Square of 5 is" + x); MathTest math = new MathTest(); math.value = 30;
Console.WriteLine("Value of contains"+math.value);
Console.WriteLine("Square of 30 is" + math.GetSquare());
Console.Read();
}
}
class MathTest
{
public int value; public int GetSquare()
{
return value * value;
} public static int GetSquareOf(int x)
{
return x * x;
} public static double GetPi()
{
return 3.14159;
}
}
}
{
class MainEntryPoint
{
public static void Main(string[] args)
{
Console.WriteLine("Pi is" + MathTest.GetPi());
int x = MathTest.GetSquareOf(5);
Console.WriteLine("Square of 5 is" + x); MathTest math = new MathTest(); math.value = 30;
Console.WriteLine("Value of contains"+math.value);
Console.WriteLine("Square of 30 is" + math.GetSquare());
Console.Read();
}
}
class MathTest
{
public int value; public int GetSquare()
{
return value * value;
} public static int GetSquareOf(int x)
{
return x * x;
} public static double GetPi()
{
return 3.14159;
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货