小编Tig*_*ran的帖子

C#用C++执行按位运算

嘿伙计们,所以我环顾四周,我似乎无法找到答案,我猜我正在寻找所有错误的条款.

无论如何这里是我的问题我一直在修改整个C++程序在C#中工作,我已经完成了很多,我在C++程序中有这个If语句

if(info[i].location & 0x8 || 
             info[i].location & 0x100|| 
                     info[i].location & 0x200)
{
    //do work
}
else
{
    return
}
Run Code Online (Sandbox Code Playgroud)

当然,当我在C#中执行此操作时,它会给我一个"操作员"||' 不能应用于'int'和'int'类型的操作数"错误

关于我的问题是什么的任何线索,我猜C#已经有了这样做的方法,因为我对这些旧的C运算符相当不熟悉

非常感谢

c# c++ bit-manipulation operator-keyword

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

c#如何计算一个月内剩余的工作日

嗨,我是新手c#和编程一般我一直试图从适应其他人的代码学习下面的代码,我已经改变了代码,因为我想计算一个月内剩余的工作日数,但问题是代码运行一个月内的天数,所以这个月有29天,但代码错误,因为代码运行到30日我无法弄清楚代码的哪一部分可以改变任何帮助会很棒

    private void days()
    {

        //Monday to Friday are business days.
        var weekends = new DayOfWeek[] { DayOfWeek.Saturday, DayOfWeek.Sunday };
        DateTime testing = DateTime.Now;



        string month1 = testing.ToString("M ");
        string year1 = testing.ToString("yyyy");
        int month = Convert.ToInt32(month1);
        int year = Convert.ToInt32(year1);


        //Fetch the amount of days in your given month.
        int daysInMonth = DateTime.DaysInMonth(year, month);
        string daysleft = testing.ToString("d ");
        int daystoday = Convert.ToInt32(daysleft);

        //Here we create an enumerable from 1 to daysInMonth,
        //and …
Run Code Online (Sandbox Code Playgroud)

c#

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

接口可以是后代吗?

我想知道:可以interface继承另一个班吗?

我试图让一个接口继承自MarshalByRefObject.

我的意图是实现接口的所有类也从该类继承.

c#

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

C#检查datagridview列是否为空

我想检查datagridview中的"many"列是否为空.

我的代码

        for (int i = 0; i < (gridx.Rows.Count - 1); i++)
        {
            col = gridx.Rows[i].Cells["code"].Value.ToString();
            col4 = gridx.Rows[i].Cells["many"].Value.ToString();                
        }

        if (col4 == "")
        {
            MessageBox.Show("Many is empty");
            this.Focus();
            return;
        } 
        else
        {
          //my code in here
        }
Run Code Online (Sandbox Code Playgroud)

但它没有显示错误"很多是空的"

请帮帮我..谢谢之前

c# datagridview

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