首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

别的CS文件中的函数如何调用

2013-12-10 
别的CS文件中的函数怎么调用?我先写了一个cs文件,如下using Systemusing System.Collections.Genericusi

别的CS文件中的函数怎么调用?
我先写了一个cs文件,如下

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

namespace hanshuku
{
    class hanshu
    {
        public const double pi =3.1415;
        
        public static double hu2shishu(double hu)
        {
            double jiaodu = hu * 180 / pi;
            int du = (int)jiaodu;
            double m = (jiaodu - du) * 60;
            int fen = (int)m;
            double s = Math.Round((m - fen) * 60, 2);
            string a = du.ToString();
            string b = fen.ToString();
            string c = s.ToString();
            if (b.Length == 1)
                b = "0" + b;
            int p = c.IndexOf(".");
            int n = c.Length;
            c = c.Remove(p, 1);
            string jiao = a + b + "." + c;
            jiaodu = double.Parse(jiao);
            return jiaodu;
        }
       
    }
}

然后,关掉之后,又创建了一个winform,应经添加了using了,为什么还不能用啊
代码如下
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using hanshuku;

namespace 实验子函数调用
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            double hu = double.Parse(this.textBox1.Text.ToString());
            //想在这里调用自己那个函数hu2shishu()

        }
    }
}

求大神解决、解释
[解决办法]
public class?hanshu

hanshu.hu2shishu(hu);
[解决办法]
用类名调用,hanshu.hu2shishu(hu);

热点排行