6.20 类库(隐藏代码类库+非隐藏代码借用)

隐藏代码类库

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 隐藏代码的类库
{
    public class chufa
    {
        /// <summary>
        /// 除法
        /// </summary>
        /// <param name="a">第一个数</param>
        /// <param name="b">第二个数</param>
        /// <returns></returns>
        public double chu(int a, int b)
        {
            return Convert.ToDouble(a / b);
        }
    }
}

 

非隐藏代码借用

 

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 using 算数;
 7 using 隐藏代码的类库;
 8 
 9 namespace 类库
10 {
11     class Program
12     {
13         static void Main(string[] args)
14         {
15             //非隐藏代码的类库
16             var a = 10;
17             var b = 20;
18 
19             suanshu g = new suanshu();
20             var d = g.jiafa(a, b);
21             var e = g.jianfa(a, b);
22             Console.WriteLine(d);
23             Console.WriteLine(e);
24             Console.WriteLine(d + "   " + e);
25             //隐藏代码的类库
26             chengfa cf = new chengfa();
27             var h = cf.cheng(a, b);
28             Console.WriteLine(h);
29 
30 
31             chufa gf = new chufa();
32             var j = gf.chu(a, b);
33             Console.WriteLine(j);//
34             Console.WriteLine(Convert.ToDecimal(a * 1.0 / b));//为什么用这种写法???
35            //默认是double 类型   在类库里面修改算法  返回值
36 
37           
38 
39             Console.ReadLine();
40 
41 
42 
43 
44 
45         }
46 
47     }
48 }

 

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 
 8 namespace 算数
 9 {
10     class suanshu
11     {
12         /// <summary>
13         /// 加法运算
14         /// </summary>
15         /// <param name="a">参数a</param>
16         /// <param name="b">参数b</param>
17         /// <returns></returns>
18         public int  jiafa(int a, int b)
19         {
20             return a + b;
21         }
22         /// <summary>
23         /// 减法运算
24         /// </summary>
25         /// <param name="a">参数a</param>
26         /// <param name="b">参数b</param>
27         /// <returns></returns>
28         public int jianfa (int a,int b)
29         {
30             return a - b;
31     }
32 
33 
34     }
35 }

 

posted @ 2016-06-20 22:17  一人饮酒醉(SeVen❤)  阅读(214)  评论(0编辑  收藏  举报