C# 在分部类中运行两个方法

C# 在分部类中运行两个方法,c#,C#,我有一个做数学运算的方法,返回一个值,然后另一个方法返回另一个值。第一种方法运行良好,但第二种方法根本无法运行。我有一种感觉,这是由于第一种方法的回归。我正在使用一个名为IX Developer的程序。它允许编写c#脚本 //-------------------------------------------------------------- // Press F1 to get help about using script. // To access an object that is

我有一个做数学运算的方法,返回一个值,然后另一个方法返回另一个值。第一种方法运行良好,但第二种方法根本无法运行。我有一种感觉,这是由于第一种方法的回归。我正在使用一个名为IX Developer的程序。它允许编写c#脚本

//--------------------------------------------------------------
// Press F1 to get help about using script.
// To access an object that is not located in the current class, start the call with Globals.
// When using events and timers be cautious not to generate memoryleaks,
// please see the help for more information.
//---------------------------------------------------------------

namespace Neo.ApplicationFramework.Generated
{
using System.Windows.Forms;
using System;
using System.Drawing;
using Neo.ApplicationFramework.Tools;
using Neo.ApplicationFramework.Common.Graphics.Logic;
using Neo.ApplicationFramework.Controls;
using Neo.ApplicationFramework.Interfaces;

public partial class ConversionMath
{
    static ConversionMath()
    {
        Globals.Tags.Tank01_Product_Level_EU.Value = 177.66;
        Globals.Tags.Tank05_Product_Level_EU.Value = 377.66;
        Globals.Tags.Tank07_Product_Level_EU.Value = 147.66;
        Globals.Tags.Tank09_Product_Level_EU.Value = 257.66;
        Globals.Tags.Tank16_Product_Level_EU.Value = 67.66;
        Globals.Tags.Tank01_Total_Capacity.Value = 300;

        Globals.Tags.Tank01_Interface_Level_EU.Value = 8.66;
        Globals.Tags.Tank05_Interface_Level_EU.Value = 90.66;
        Globals.Tags.Tank01_Interface_Level_EU.Value = 142.66;
        Globals.Tags.Tank09_Interface_Level_EU.Value = 253.66;
        Globals.Tags.Tank16_Interface_Level_EU.Value = 64.66;

        Globals.Tags.Tank01_Product_Level_DISP.Value = 
            ConversionMath.LevelConverter(Globals.Tags.Tank01_Product_Level_EU.Value);
        Globals.Tags.Tank02_Product_Level_DISP.Value = 
            ConversionMath.LevelConverter(Globals.Tags.Tank02_Product_Level_EU.Value);

        //Interface Levels
        Globals.Tags.Tank01_Interface_Level_DISP.Value = 
            ConversionMath.LevelConverter(Globals.Tags.Tank01_Interface_Level_EU.Value);
        Globals.Tags.Tank02_Interface_Level_DISP.Value = 
            ConversionMath.LevelConverter(Globals.Tags.Tank02_Interface_Level_EU.Value);
    }

    public static string LevelConverter(float Product_Level_EU )
    {
        float fFT = Product_Level_EU / 12;
        int levelFT = (int)fFT;
        float levelIN = Product_Level_EU - levelFT * 12;
        string Product_Level_Disp = levelFT.ToString() + "'" + " " + levelIN.ToString() + '"';

        return Product_Level_Disp;
    }

    static PercentageAvailable()
    {   
        Globals.Tags.Tank01_Product_Level_EU.Value = 177.66;
        Globals.Tags.Tank01_Total_Capacity.Value = 300;

        Globals.Tags.Tank01_Avail_Vol.Value = ConversionMath.AvailPct(Globals.Tags.Tank01_Total_Capacity.Value, Globals.Tags.Tank01_Product_Level_EU.Value );
    }

    public static float AvailPct(float TotalCapacity, float Product_Level_EU)
    {
        float AvailPCT = (Product_Level_EU / TotalCapacity) * 100 ;
        return AvailPCT;
    }
}
}

谢谢你的回复。我弄明白了。当我只需要第二个构造函数时,我正在尝试使用第二个构造函数。这就是我的结局

   //--------------------------------------------------------------// Press F1 to get help about using script.// To access an object that is not located in the current class, start the call with Globals.// When using events and timers be cautious not to generate memoryleaks,// please see the help for more information.//---------------------------------------------------------------namespace Neo.ApplicationFramework.Generated{
using System.Windows.Forms;
using System;
using System.Drawing;
using Neo.ApplicationFramework.Tools;
using Neo.ApplicationFramework.Common.Graphics.Logic;
using Neo.ApplicationFramework.Controls;
using Neo.ApplicationFramework.Interfaces;
public partial class ConversionMath
{
static ConversionMath()

{   

Globals.Tags.Tank01_Product_Level_EU.Value = 177.66;
Globals.Tags.Tank05_Product_Level_EU.Value = 377.66;
Globals.Tags.Tank07_Product_Level_EU.Value = 147.66;
Globals.Tags.Tank09_Product_Level_EU.Value = 257.66;
Globals.Tags.Tank16_Product_Level_EU.Value = 67.66;
Globals.Tags.Tank01_Total_Capacity.Value = 300; 

Globals.Tags.Tank01_Interface_Level_EU.Value = 8.66;
Globals.Tags.Tank05_Interface_Level_EU.Value = 90.66;
Globals.Tags.Tank01_Interface_Level_EU.Value = 142.66;
Globals.Tags.Tank09_Interface_Level_EU.Value = 253.66;
Globals.Tags.Tank16_Interface_Level_EU.Value = 64.66;

Globals.Tags.Tank01_Product_Level_DISP.Value = ConversionMath.LevelConverter(Globals.Tags.Tank01_Product_Level_EU.Value);
Globals.Tags.Tank02_Product_Level_DISP.Value = ConversionMath.LevelConverter(Globals.Tags.Tank02_Product_Level_EU.Value);

//Interface Levels  
Globals.Tags.Tank01_Interface_Level_DISP.Value = ConversionMath.LevelConverter(Globals.Tags.Tank01_Interface_Level_EU.Value);
Globals.Tags.Tank02_Interface_Level_DISP.Value = ConversionMath.LevelConverter(Globals.Tags.Tank02_Interface_Level_EU.Value);

Globals.Tags.Tank01_Total_Capacity.Value = 300; 
Globals.Tags.Tank01_Avail_Vol.Value = ConversionMath.AvailPct(Globals.Tags.Tank01_Total_Capacity.Value, Globals.Tags.Tank01_Product_Level_EU.Value );

}   

public static string LevelConverter(float Product_Level_EU )
{
float fFT = Product_Level_EU / 12;
int levelFT = (int)fFT;
float levelIN = Product_Level_EU - levelFT * 12;
string Product_Level_Disp = levelFT.ToString() + "'" + " " + levelIN.ToString() + '"';
return Product_Level_Disp;
}
public static float AvailPct(float TotalCapacity, float TankVol)
{
float AvailPCT = (TankVol / TotalCapacity) * 100 ;  
return AvailPCT;
}   

}

}

调用代码是什么?什么不起作用?“它不起作用”不是一个问题陈述。我很抱歉,第一个方法运行良好并返回值,第二个方法没有。代码是连续运行的,它不是由事件触发的。哪个函数是您遇到问题的?那里有3个函数(+1个静态构造函数),其中只有2个函数将返回任何内容。你是说
AvailPct
还是
LevelConverter
?具体来说,方法1(成功的方法)和方法2(失败的方法)的名称是什么?