小编Ric*_*ngo的帖子

任何支持.NET Micro Framework 4.2的简单日志库?

log4net和NLog支持Compact Framework,但不支持Micro Framework.Micro Framework是否有这些项目的端口?

.net c# logging .net-micro-framework

12
推荐指数
0
解决办法
456
查看次数

如何使用 Blazor 渲染知道其内容类型的字节数组?

以下代码对应于 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)

c# arrays rendering blazor

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

如何避免在foreach体中进行空检查?

如何避免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)

.net c# foreach null

-1
推荐指数
1
解决办法
419
查看次数

标签 统计

c# ×3

.net ×2

.net-micro-framework ×1

arrays ×1

blazor ×1

foreach ×1

logging ×1

null ×1

rendering ×1