小编Chr*_*ris的帖子

如何从if语句中的布尔值中取出if语句

我有类似的东西

bool a = true;
bool b = true;
bool plot = true;
if(plot)
{
    if(a)
    {
        if(b)
            b = false;
        else
            b = true;
    //do some meaningful stuff here
    }
//some more stuff here that needs to be executed
}
Run Code Online (Sandbox Code Playgroud)

我想打破if测试b何时变为false的语句.有点喜欢休息并继续循环.有任何想法吗?编辑:抱歉忘了包含大if语句.我想打破if(a)当b是假的但是没有突破if(plot).

.net c# if-statement

6
推荐指数
3
解决办法
5万
查看次数

如何在函数代码之前先调用默认构造函数?

我有两个构造函数:

public ViewDigiFiles()
{
    InitializeComponent();
    InitializeMyGLControl();
    InitializeMyScrollBar();
    InitializeMouseEvents();
    InitializeKeyboardControls();
    InitializeContextMenu();
    InitializeComboBox();
    InitializeToolStripView();
    InitializeListBox();
    setToDefaultScale();
}

public ViewDigiFiles(List<SelectDataLog.DataLog> d)
    :this()
{
    //how to execute this line first before calling this()?
    datalogList = d;
}
Run Code Online (Sandbox Code Playgroud)

有没有办法datalogList = d;在初始化函数之前执行而不复制并粘贴其下的所有内容?谢谢!

c# syntax constructor

2
推荐指数
1
解决办法
65
查看次数

如何格式化字符串?

我有一个字符串"5-13-2013"​​我想使它看起来像"051313"所有三个字段(月,日,年)必须有2位数,如果它只有一个,我需要在前面添加一个零

这么简单吗?

c# string date

1
推荐指数
1
解决办法
86
查看次数

为什么我的第二个变量值在更新第一个时会发生变化?

我有一个带有两个Datalog类变量的Form

public partial class ModifyDataForm : Form
{
    public DataLog DLog;
    private DataLog copyCurrent;

    public ModifyDataForm(DataLog log, int selectIndex = 0)
    {
        InitializeComponent();
        DLog = (DataLog)log.Clone();
        copyCurrent = (DataLog)log.Clone();
    }
}
Run Code Online (Sandbox Code Playgroud)

当我更新DLog的值时,copyCurrent的值也会改变,为什么?

我更新变量的函数如下

    private void smooth_Click(object sender, EventArgs e)
    {
        int NValues; int POrder;
        if (getSmoothParameters(out NValues, out POrder))//parameters are valid
        {
            float[] yvalues = DataLog.convertStringArrayToFloats(DLog.Data[labelIndex]);
            float[] newyvalues = Filters.smooth.SavitzkyGolay(yvalues, NValues, POrder);



            //I am updating the values of DLog here,
            //but the values of copyCurrent also changes
            DLog.Data[labelIndex] = Array.ConvertAll(newyvalues, …
Run Code Online (Sandbox Code Playgroud)

c# class access-levels

1
推荐指数
1
解决办法
488
查看次数

标签 统计

c# ×4

.net ×1

access-levels ×1

class ×1

constructor ×1

date ×1

if-statement ×1

string ×1

syntax ×1