赞
踩
类库的引用
还可以自己引用类库:解决方案-添加-新建项目
主程序
using System; using System.Windows.Forms; using Tools; namespace ConsoleApp2 { class Program { static void Main(string[] args) { //Console.WriteLine("helloword"); // Form form = new Form(); // form.ShowDialog(); double result = Calculator.Mul(3, 4); Console.WriteLine(result); } } }
在引用里添加自己创建的类库
类库程序
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Tools { public class Calculator { public static double Add(double a, double b) { return a + b; } public static double Sub(double a, double b) { return a - b; } public static double Mul (double a, double b) { return a * b; } public static double Div(double a, double b) { if (b == 0) { return double.PositiveInfinity; } else { return a / b; } } } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。