小编spa*_*jce的帖子

通过输入进入

我有以下场景:

文章表

id | description | supplierID
_____________________________
1  | Testarticle | 1
Run Code Online (Sandbox Code Playgroud)

供应商表

id | description 
_______________________
1  | Example Industries
Run Code Online (Sandbox Code Playgroud)

例如SELECT * FROM articles WHERE ID=1,在阅读文章时, 我还需要在结果中提供供应商描述.

什么是实现这一目标的适当方法?

.net c# sql sql-server-ce

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

需要一种更好的方法来删除字符串中的模式

我有一个方法,删除字符串上的描述字,但我相信有更有效的方法来做到这一点.

iMonster可以像脂肪兽人盗贼,和我想删除的脂肪.

    private static string[] _adjectives = { "angry", 
                                            "big", 
                                            "fat", 
                                            "happy",
                                            "large", 
                                            "nasty", 
                                            "fierce", 
                                            "thin",
                                            "small", 
                                            "tall", 
                                            "short" };

    private static string RemoveMonsterAdjective(string iMonster)
    {
        foreach (string adjective in _adjectives)
        {
            if (iMonster.Contains(adjective))
            {
                iMonster = iMonster.Replace(adjective, "").Trim();
                break;
            }
        }
        return iMonster;
    }
Run Code Online (Sandbox Code Playgroud)

希望有人可以帮助我.提前致谢.

c# arrays string foreach

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

锁定/监视多个线程

在.NET中,假设thread A锁定一个对象.同时,thread Bthread C被阻塞并等待对象由被解锁thread A.

现在,thread A解锁了对象.接下来会选择哪个线程(B或C)?怎么决定?

.net c# multithreading locking monitor

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

在运行时创建控件

我无法设法从textboxes运行时创建的值.

我希望用户从a中选择一些内容checkedlistbox,并textboxes在每次单击按钮时输入他想要的任何值.

我怎么能得到那些名字texboxes?他们真的存在吗?我是初学者,我真的不明白它们是如何创建的.

这是我创建的代码textboxes.

    private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        int x = 466;
        int y = 84;
        foreach (var itemChecked in checkedListBox1.CheckedItems)
        {
            int i = 0;
            TextBox tb = new TextBox();
            tb.Location = new Point(x, y);
            tb.Name = "txtBox" + i++.ToString();
            Controls.Add(tb);
            y += 30;
     }
Run Code Online (Sandbox Code Playgroud)

.net c# foreach textbox

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

For loop和If语句

int i;
int[] mArray = new int[5];

for (i = 0; i < mArray.Length; i++)
{
    Console.WriteLine("Please enter a number:");
    mArray[i] = Convert.ToInt32(Console.ReadLine());

    if (mArray[i] >= 50 && mArray[i] <= 10)
    {
        Console.WriteLine("Please enter numbers only between 10 and 50.");
        mArray[i] = Convert.ToInt32(Console.ReadLine());
    }

}
Run Code Online (Sandbox Code Playgroud)

当它有两个规则时,似乎无法获得if语句 if (mArray[i] >= 50 && mArray[i] <= 10)

但它适用于1规则 if (mArray[i] >= 50)

c# for-loop if-statement

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

LINQ查询中的Where子句使用函数

我有一段代码:

IList<Opportunity> filteredOpportunityProperties = new List<Opportunity>();
List<LookupWithIntId> selectedProperties = opportunityFilter.PropertyTypes;
List<string> propertyTypes = selectedProperties.Select(item => item.Name).ToList();

opportunities.Where((item) =>
    {
        string productType = item.Properties[0].ProductType;
        bool propertyMatch = propertyTypes.Any(propTypes => productType.Contains(propTypes));
        if (propertyMatch) select item;
    });
Run Code Online (Sandbox Code Playgroud)

如果条件匹配,我想要选择该项.但是,我收到错误:

嵌入式语句不能是声明或带标签的语句

有什么建议!

c# linq

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

拆分期间分为月份

我有以下日期时间:

Start = 15/12/2012 13:00:00
End   = 16/02/2013 14:00:00
Run Code Online (Sandbox Code Playgroud)

我怎样才能将它分成3个部分?

- 15-12-2012 13:00:00 -> 01-01-2013 00:00:00
- 01-01-2013 00:00:00 -> 01-02-2013 00:00:00
- 01-02-2013 00:00:00 -> 16-02-2013 14:00:00
Run Code Online (Sandbox Code Playgroud)

总时间跨度必须保持不变.LINQ可以轻松完成吗?

c# datetime

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

获取具体日期

我正在使用C#中的日期,需要计算更多日期.拿走当前datetime.

如何获得以下值?

  • 一天的结束
  • 月底
  • 年末

c# datetime date

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

NSUrlConnection和NSMutableUrlConnection之间的区别

NSUrlConnection和之间有什么区别NSMutableUrlConnection

iphone cocoa cocoa-touch

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

在Lambda或Linq中验证数组到数组存在

如何检查是否array2是子集array1?换句话说,我要检查的所有元素是否array2存在于array1或不?我想要解决方案LambdaLinq.

int[] array1 = {6, 3, 1, 4, 5, 2};
int[] array2 = {1, 2, 3};
Run Code Online (Sandbox Code Playgroud)

c# linq arrays lambda

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

吸气者应该怎么样

我在c#中看到过这种代码:

  private int id {get;set;}
Run Code Online (Sandbox Code Playgroud)

但我只会为该字段创建getter,如果有get和set,则与public字段相同,唯一的方法是:

public int getId(){return id;}
Run Code Online (Sandbox Code Playgroud)

如何在VS2010中自动生成getter

c# visual-studio-2010 getter-setter

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

确认消息

如果用户检查Checkbox,我如何编码显示MessageBox.Show("...",使用YesNoCancel消息框中的按钮,当用户单击否时,另一个MessageBox.Show弹出?

到目前为止我的代码是这样的,它不起作用:

private void lipsCheckBox_CheckedChanged(object sender, EventArgs e)
    {
        if (lipsCheckBox.Checked = MessageBox.Show("...?",
            "Want something else?",
            MessageBoxButtons.YesNoCancel, MessageBox.Show("...?",
            "Yea, Burt's bees?",
            MessageBoxButtons.YesNoCancel, MessageBox.Show("...??",
            "Hell yea LipxMedx?",
            MessageBoxButtons.YesNoCancel),
            MessageBoxIcon.Question);
    }
Run Code Online (Sandbox Code Playgroud)

c# messagebox winforms

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