public static bool ContainsAll<T>(IEnumerable<T> source, IEnumerable<T> values)
{
return values.All(value => source.Contains(value));
}
2019年11月29日 星期五
[C#] Lambda All() check ListA all in ListB
2019年11月26日 星期二
新增 net core project
$ dotnet new web -o <專案名稱>
dotnet help 可以查看專案型態的參數
安裝npm $ npm install 檢查npm安裝版本
$ npm -v
init npm
$npm init
如果沒有要設定專案資訊 直接Enter到底
結束之後 會再package.json寫入設定
npm安裝套件 ex jquery
$ npm install jquery
安裝LibMan
$ dotnet tool install -g Microsoft.Web.LibraryManager.Cli
Run
$ dotnet run
Ref microsoft microsoft-SingleR install
2019年11月24日 星期日
.Net Core Console使用依賴注入
- public static async Task Main(string[] args)
- {
- // 取得設定檔
- IConfiguration config = new ConfigurationBuilder()
- .AddJsonFile("appsettings.json", true, true)
- .Build();
- // 建立容器
- var serviceCollection = new ServiceCollection();
- // 註冊服務
- serviceCollection.AddTransient
(); serviceCollection.AddTransient (); // 加入SqlServer 連線字串 serviceCollection.AddDbContext (options => options.UseSqlServer(config["ConnectionStrings:DefaultConnection"])); // 建立依賴服務提供者 var serviceProvider = serviceCollection.BuildServiceProvider(); // 執行 await serviceProvider.GetRequiredService ().Run(); }
C# 比較字串不分大小寫
除了把字串ToUpper() 或 ToLower() 以外
還可以用 String.Compare()
而另外一種我最常用來做搜尋的方法是Contains()
還可以用 String.Compare()
回傳為0 即相等
- //最後一個參數改成true 就可以忽略大小寫
- String.Compare(strSource, strTarget, true)
而另外一種我最常用來做搜尋的方法是Contains()
- sourceString.Contains("Search-Word", StringComparison.InvariantCultureIgnoreCase,
- new System.Globalization.CultureInfo("en-US")));
訂閱:
文章 (Atom)