您的位置:首页 > 编程语言 > C#

使用另外一个文件中的类—C#基础回顾

2017-07-24 00:00 218 查看
MathLibrary.cs

/*
author:frank
datetime:2017-7-20 10:38:03
*/
using System;

namespace Sample
{
public class MathLib
{
public int Add(int x,int y)
{
return x + y;
}
}
}

2.9.cs

/*
author:frank
datetime:2017-7-20 10:32:58

控制台编译的时候可以指定输出的类型:

/t:exe 控制台应用程序(默认)
/t:library 带有清单的类库
/t:module 没有清单的组件
/t:winexe Windows应用程序(没有控制台窗口)

编译命令例子:csc /t:exe 2.9.cs /r:MathLibrary.dll
*/
using System;

namespace Sample
{
public class Program
{
public static void Main(string[] args)
{
MathLib mathObj = new  MathLib();//如果不是同一命名空间里面的就要对其进行引用
Console.WriteLine(mathObj.Add(7,8));
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  C# Studio
相关文章推荐