Questions tagged «coreclr»

21
如何在Asp.Net Core中注册同一接口的多个实现?
我有从相同接口派生的服务。 public interface IService { } public class ServiceA : IService { } public class ServiceB : IService { } public class ServiceC : IService { } 通常,其他IoC容器例如 Unity允许您通过一些Key区分它们的具体实现来注册。 在ASP.NET Core中,如何注册这些服务并在运行时基于某些键解析它们? 我看不到任何Add带有key或name参数的Service方法,这些方法通常用于区分具体实现。 public void ConfigureServices(IServiceCollection services) { // How do I register services of the same interface? } public MyController:Controller …


2
为什么在发布和调试模式下代码行为不同?
考虑以下代码: private static void Main(string[] args) { var ar = new double[] { 100 }; FillTo(ref ar, 5); Console.WriteLine(string.Join(",", ar.Select(a => a.ToString()).ToArray())); } public static void FillTo(ref double[] dd, int N) { if (dd.Length >= N) return; double[] Old = dd; double d = double.NaN; if (Old.Length > 0) d …
84 c#  .net  .net-core  coreclr 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.