log4net和NLog支持Compact Framework,但不支持Micro Framework.Micro Framework是否有这些项目的端口?
以下代码对应于 Blazor 服务器端页面:
<pre>
@page "/ShowFile/{Id:guid}"
//// What to put here to let the browser render the byte array stored on this.Model
//// Also how to specify the content type of the response?
@code
{
[Parameter]
public Guid Id { get; set; }
private byte[] Model { get; set; }
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
//// Gets the byte array of a file based on its identifier.
this.Model = await this.GetFile(this.Id).ConfigureAwait(false);
}
}
</pre>
In ASP.NET MVC …Run Code Online (Sandbox Code Playgroud) 如何避免foreach语句中的条件,但同时省略了可能的null元素的处理?
public class MyObject
{
public int Value = 0;
public MyObject(int value) : base()
{
Value = value;
}
}
class Program
{
static void Main(string[] args)
{
var list = new List<MyObject>()
{
new MyObject(1),
new MyObject(2),
null,
new MyObject(4),
new MyObject(5)
};
foreach (MyObject obj in list)
{
if (obj != null)
{
Console.WriteLine(obj.Value);
}
}
list.ForEach(obj =>
{
if (obj != null)
{
Console.WriteLine(obj.Value);
}
});
}
}
Run Code Online (Sandbox Code Playgroud)