vs2005怎样引用system.math类

来源:百度知道 编辑:UC知道 时间:2024/07/03 03:19:44
using System;
using System.Collections.Generic;
using System.Text;
#include "Math.h"
using System.Math;

namespace 三角形斜边长
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("在下面输入两个数据,分别代表直角三角形的的两个直角边:");
int a, b;
a = Console.Read; b = Console.Read;
//string currentline = Console.ReadLine();

int c = Math.Sqrt(a*a+b*b);
Console.WriteLine("你输入的三角形斜边长为{0}", c);
}
}
}
编译报错,说System.Math不是命名空间,它是一个类
这样会出新的错:
无法将方法组“Read”转换为非委托类型int。您是要调用方法吗?

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

namespace 三角形斜边长
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("在下面输入两个数据,分别代表直角三角形的的两个直角边:");
int a, b;
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());

int c = Math.Sqrt(a*a+b*b);
Console.WriteLine("你输入的三角形斜边长为{0}", c);
}
}
}

将#include "Math.h"
using System.Math;
去掉就好了!
Math是命名空间System中的一个类!

a =Convert.ToInt32( Console.ReadLine());
b =Convert.ToInt32( Console.ReadLine());