C#:需要专家建议。普通班 [英] C#: Need expert advice. Common Class

查看:66
本文介绍了C#:需要专家建议。普通班的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在程序内部,我有一个重复的方法,在同一个类中具有不同的值,并且对于基于模型标准的其他类也是相同的。

我使用普通类的最佳方法是什么对于所有模型?

Inside program, I have a repeated Method with different value in same class and also same for other classes based on model criteria.
What is the best way for me to use common class for all model?

*参数值是从SQL DB调用

*Parameter value is call from SQL DB

以下是当前源代码

class ParameterSetting_ModelAA
    {
        public void ParameterSetting01(out HTuple hv_DarkThreshold, out HTuple hv_MinDarkThreshold,
            out HTuple hv_MaxDarkThreshold)
        {
            hv_DarkThreshold = 30;
            hv_MinDarkThreshold = 10;
            hv_MaxDarkThreshold = 140;
            return;
        }
        public void ParameterSetting02(out HTuple hv_DarkThreshold, out HTuple hv_MinDarkThreshold,
            out HTuple hv_MaxDarkThreshold,)
        {

            hv_DarkThreshold = 10;
            hv_MinDarkThreshold = 0;
            hv_MaxDarkThreshold = 110;
            return;
        }
        public void ParameterSetting03(out HTuple hv_DarkThreshold, out HTuple hv_MinDarkThreshold,
            out HTuple hv_MaxDarkThreshold)
        {
            hv_DarkThreshold = 20;
            hv_MinDarkThreshold = 0;
            hv_MaxDarkThreshold = 150;
            return;
        }
}

class ParameterSetting_ModelBB
    {
        public void ParameterSetting01(out HTuple hv_DarkThreshold, out HTuple hv_MinDarkThreshold,
            out HTuple hv_MaxDarkThreshold)
        {
            hv_DarkThreshold = 0;
            hv_MinDarkThreshold = 10;
            hv_MaxDarkThreshold = 200;
            return;
        }
        public void ParameterSetting02(out HTuple hv_DarkThreshold, out HTuple hv_MinDarkThreshold,
            out HTuple hv_MaxDarkThreshold,)
        {

            hv_DarkThreshold = 80;
            hv_MinDarkThreshold = 50;
            hv_MaxDarkThreshold = 160;
            return;
        }
        public void ParameterSetting03(out HTuple hv_DarkThreshold, out HTuple hv_MinDarkThreshold,
            out HTuple hv_MaxDarkThreshold)
        {
            hv_DarkThreshold = 70;
            hv_MinDarkThreshold = 80;
            hv_MaxDarkThreshold = 120;
            return;
        }
}

请帮助和建议。

提前致谢

推荐答案

(请注意,您正在使用类作为名称空间)

( Notice that you are using classes as namespaces )

这取决于某些因素。

考虑到这些类只提供常量值:

Considering that those classes provide just constant values:

1)如果使用它们的代码,执行 使用常量值
仅从1个类,然后我建议 简单枚举

1) If the code that use them, do use the constant values from just 1 class, then I suggest simple enums.

2)如果使用它们的代码,确实使用来自所有类的常量值
,然后我建议  嵌套枚举

2) If the code that use them, do use the constant values from all classes, then I suggest nested enums.

3)...


这篇关于C#:需要专家建议。普通班的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆