Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c# 语法 #7

Open
topcss opened this issue Dec 17, 2018 · 3 comments
Open

c# 语法 #7

topcss opened this issue Dec 17, 2018 · 3 comments
Labels

Comments

@topcss
Copy link
Owner

topcss commented Dec 17, 2018

主线程碰到await时会立即返回,继续以非阻塞形式执行主线程下面的逻辑。当await耗时操作完成时,继续执行Async1下面的逻辑

static async void Async2()
    {
        await Task.Run(() => { Thread.Sleep(500); Console.WriteLine("bbb"); });
        Console.WriteLine("ccc");
    }
  Async2();
  Console.WriteLine("aaa");
@topcss
Copy link
Owner Author

topcss commented Jan 14, 2019

c# 确定dynamic类型的数据对象是否存在某个属性

public static bool IsPropertyExist(dynamic data, string propertyname)
  {
    if (data is ExpandoObject)
      return ((IDictionary<string, object>)data).ContainsKey(propertyname);
    return data.GetType().GetProperty(propertyname) != null;
  }

@topcss
Copy link
Owner Author

topcss commented Mar 28, 2019

使用LINQ从List集合中获取最后N条数据记录的方法?
collection.Skip(Math.Max(0, collection.Count() - N));

@topcss
Copy link
Owner Author

topcss commented Apr 4, 2019

//使用"," 分隔符号将List泛型集合合并成字符串
string strTemp1 = string.Join(",", list.ToArray());

@topcss topcss added the 🔪C# label Jun 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant