小编Bri*_*sen的帖子

不区分大小写的字符串搜索

使用非大小写敏感搜索搜索单词文本的最快捷最有效的方法是什么.

例如,这是我要搜索的文字:

string textTosearch = "Here is a paragraph or Some text. Here is some more text".
Run Code Online (Sandbox Code Playgroud)

如果我想找到"Some"和"some"的索引,是否有一个.Net类可以执行此操作,或者我需要使用类似正则表达式的东西.

非常感谢您的想法.

我正在使用visual studio 2008.

.net c# string .net-3.5

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

如何在NHibernate中将参数传递给IN运算符?

HI,

我正在尝试,为一个命名查询(本机sql)传递一个长数组,以便在IN STATEMENT中使用:像这样:

(...)WHERE Identificator IN(:pIdes)

我尝试传递我的ides []:

 ctx.GetNamedQuery("NamedQueryName")                                          
                   .SetParameter<long[]>("pIdes", Identificators)
                   .List<EmpreendimentoInputReport>();
Run Code Online (Sandbox Code Playgroud)

并作为一个字符串

 ctx.GetNamedQuery("NamedQueryName")                                          
                   .SetParameter<string>("pIdes", Identificators)
                   .List<EmpreendimentoInputReport>();
Run Code Online (Sandbox Code Playgroud)

当参数是一个字符串返回什么都没有,whem是一个long []返回这个oracle错误:

"Oracle.DataAccess.Client.OracleException:ORA-00932:tipos de dados inconsistentes:esperava NUMBER obteve BINARY"

有人可以帮帮我吗?

c# oracle nhibernate query-parameters ora-00932

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

构造函数上的static修饰符意味着什么?

我在工作中看到了这种代码:

class FooPlugin : IPlugin // IPlugin is a Microsoft CRM component, it has something special about it's execution
{
  static FooPlugin()
  {
     SomeObject.StaticFunction(); // The guy who wrote it said it's meaningful to this question but he can't remember why.
  }
}
Run Code Online (Sandbox Code Playgroud)

知道构造函数上的静态修饰符是什么意思,为什么在这种情况下它是必需的?

c#

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

使用F#进行XML序列化

我总共是F#n00b,所以希望我能给您足够的信息。我创建了一个称为记录的类。我使用数据库中的数据创建该类的几个实例。然后,我将每个记录添加到记录列表中。我想用这些记录制作一个xml文档。

//this is the record data type i created. I also created a sender and recipient data
//type but those are probably not neccessary to understand the issue
type record(id:int, sender:sender, ?recipients: recipient list ) =  
    let mutable id: int = id
    let mutable typ = "Message"
    let mutable creation = creation()
    let mutable sender  = sender
    let mutable recipients = recipients

    [<XmlIgnore()>] 
    [<XmlArrayAttribute("recipients")>]
    [<XmlArrayItem(typeof<recipient>, ElementName = "recipient")>]
    member this.Recipients with get() = recipients and set v = recipients <- …
Run Code Online (Sandbox Code Playgroud)

xml f# xml-serialization

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

如何从microsoft为.NET 4 C#编译器指定.NET版本?

我想通过Microsoft .NET 4.0 Runtime中的CSharpCodeProvider编译.NET 2.0 DLL.这可能吗?

顺便说一句,Mono C#编译器可以做到这一点.使用sdk参数(支持2和4).

.net c# compiler-construction c#-4.0

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

使用 xml.Load 打开 HTML 文档

我想通过以这种方式创建 XMLDocument 来打开一个 HTML 文档(作为从 StreamReader 中检索的字符串):

XmlDocument doc = new XmlDocument

doc.Load(string containing the retrieved document).
Run Code Online (Sandbox Code Playgroud)

但由于 HTML 文档包含这个头:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > 
Run Code Online (Sandbox Code Playgroud)

它告诉我该文档无效...有什么办法可以解决这个问题?

html c# xml document

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

请解释一下!SyncBlk的windbg命令

首先,是否有一个获取每个sos命令的帮助和参数的命令windbg

其次,我想了解!syncblk输出

Index SyncBlock MonitorHeld Recursion Owning Thread Info  SyncBlock Owner
  201 05b9493c          979         1 05bc1040   bcc  45   022f3490 System.Collections.ArrayList
 2875 05b4c914            1         1 17b99e10  1af8 290   024862d8 MyClass
 2945 05b4b66c            1         1 17d1a290  12c0 752   02482940 MyClass
Run Code Online (Sandbox Code Playgroud)

MonitorHeld显示由持有的监视器#synblk.写入1和读取2,但列的其余部分是什么意思?

说我有一个C#代码

MyClass MyObj;
MyObj = new MyClass();
Run Code Online (Sandbox Code Playgroud)

现在,如果我这样做

lock (MyObj)
{
}
Run Code Online (Sandbox Code Playgroud)

请问syncblk所有者列秀"MyClass的"?同样,当我运行此!SyncBlk命令时,它到底显示了什么?它是否显示了lock()and Monitor.EnterMutex()以及其他锁定机制的数量?

c# command windbg sos

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

跳过Console.ReadLine

Console.ReadLine()使用mono filename.exe编译后运行代码时,忽略C#命令gmcs filename.cs.可能会发生什么?即使我尝试运行简单的代码,它也会直接跳到最后,好像它什么都没有运行一样.

static void Main(string[] args) {
    string value = Console.ReadLine();
    Console.WriteLine("You entered: {0}", value);
    Console.WriteLine("Press ENTER to continue...");
    Console.ReadLine();   // Returns immediately.
    Console.WriteLine("Continuing....");
}
Run Code Online (Sandbox Code Playgroud)

c# readline

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

在try catch c#中处理AccessViolation异常

如何在try-catch块中捕获AccessViolation异常:

这是下面的代码:

public static BP GetBloodPressure(string vendorid, string productid)
{
    BP Result = new BP();
    try
    {
        GETBPData BPreadings = new GETBPData();
        UInt16 VendorId = Convert.ToUInt16(vendorid, 16);
        UInt16 ProductId = Convert.ToUInt16(productid, 16);

        if (HealthMonitorData.HidDataTap_GetBloodPressure(VendorId, ProductId, ref BPreadings)) // error here
        {

            if (BPreadings.ucSystolic == 0 && BPreadings.ucDiastolic == 0 && BPreadings.DeviceId1 == 0 && BPreadings.DeviceId2 == 0 && BPreadings.ucPulse == 0)
            {
                Result = null;

            }
            else
            {
                Result.UcSystolic = BPreadings.ucSystolic;
                Result.UcDiastolic = BPreadings.ucDiastolic;
                Result.UcPulse = BPreadings.ucPulse;
                Result.DeviceId1 = BPreadings.DeviceId1; …
Run Code Online (Sandbox Code Playgroud)

wpf try-catch mvvm c#-4.0

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

如何在我的XNA游戏中实现类似OnExit的方法?

C#XNA游戏是否有任何方法可以检测用户是否点击了十字按钮来关闭程序,或按下ALT + F4键来关闭..?

可能会从KeyBoardState中检测到ALT + F4键,但如何检测单击十字按钮以关闭窗口?

我需要这个,以便当用户通过任何方式关闭游戏时我可以关闭所有运行的线程..我现在有一些线程仍在运行时关闭游戏,使音乐仍然播放:P

请注意,该方法必须兼容Windows和Xbox 360,因为游戏应该在这两个平台上运行(可能也是Zune).

c# xna visual-studio

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