小编use*_*169的帖子

为什么来自线程教程的MSDN示例崩溃?

来自MSDN "线程教程"的示例4示例下面的
代码错误在注释"--- errors is here ---".
怎么了?

using System;
using System.Threading;

public class MutexSample
{
    static Mutex gM1;
    static Mutex gM2;
    const int ITERS = 100;
    static AutoResetEvent Event1 = new AutoResetEvent(false);
    static AutoResetEvent Event2 = new AutoResetEvent(false);
    static AutoResetEvent Event3 = new AutoResetEvent(false);
    static AutoResetEvent Event4 = new AutoResetEvent(false);

    public static void Main(String[] args)
    {
        Console.WriteLine("Mutex Sample ...");
        // Create Mutex initialOwned, with name of "MyMutex".
        gM1 = new Mutex(true, "MyMutex");
        // Create Mutex initialOwned, with no …
Run Code Online (Sandbox Code Playgroud)

c# multithreading synchronization mutex thread-safety

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

c#,lambda表达式,错误在哪里?

我有这个方法

    public static List<Contact> Load(string filename)
    {
        if (!File.Exists(filename))
        {
            throw new FileNotFoundException("Data file could not be found", filename);

        }
        var contacts = 
            System.Xml.Linq.XDocument.Load(filename).Root.Elements("Contact").Select
            (
                x => new Contact() { //errors out here, XXXXXX
                            FirstName = (string)x.Element("FirstName"),
                            LastName = (string)x.Element("LastName"),
                            Email = (string)x.Element("Email")
                         }
            );
        return contacts.ToList();// is this line correct?, it should return List...
    }
Run Code Online (Sandbox Code Playgroud)

我有Contact.xml和Contact元素.

<Contacts>
    <Contact>
        <FirstName>Mike</FirstName>
        <LastName>Phipps</LastName>
        <Email>mike@contoso.com</Email>
    </Contact>
    <Contact>
        <FirstName>Holly</FirstName>
        <LastName>Holt</LastName>
        <Email>holly@contoso.com</Email>
    </Contact>
    <Contact>
        <FirstName>Liz</FirstName>
        <LastName>Keyser</LastName>
    </Contact>
</Contacts>
Run Code Online (Sandbox Code Playgroud)

我有一个contact.cs与此代码

public class Contact
{
    public Contact(string …
Run Code Online (Sandbox Code Playgroud)

c# lambda

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