小编Saa*_*ram的帖子

如何在 Blazor 应用程序中加载 .gltf

我正在尝试使用 Three.js 将 .gltf 模型加载到我的 Blazor 应用程序中。 在此处输入图片说明 但是,服务器不提供此类文件。 在此处输入图片说明 我知道必须添加 MIME 类型,但由于某些原因,无法使用 Blazor Web 应用程序完成此操作,因为 Startup.cs 中的“app”变量是IComponentsApplicationBuilder. 任何人都可以帮助我解决这个问题。

static-files three.js gltf blazor

2
推荐指数
1
解决办法
1668
查看次数

如何在C#中的运行时为函数参数赋值默认值

我有以下课程:

public class Location
{
    private int X { get; set; }
    private int Y { get; set; }
    private int Z { get; set; }

    public UpdateLocation(int X, int Y, int Z)
    {
        this.X = X;
        this.Y = Y;
        this.Z = Z;
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,有时我需要更新其中一些参数和所有参数.所以我在考虑一种初始化函数参数的方法,而不是将它们分配给局部变量,如:

public UpdateLocation(int X = this.X, int Y = this.Y, int Z = this.Z)
{
    this.X = X;
    this.Y = Y;
    this.Z = Z;
}
Run Code Online (Sandbox Code Playgroud)

所以我可以像这样调用函数:

UpdateLocation(Z:1509);
Run Code Online (Sandbox Code Playgroud)

但显然,这不起作用,因为参数默认值必须是编译时常量.任何想法如何解决这个问题,而不创建三个不同的更新功能(或更多)来更新这些变量?

c# arguments function

0
推荐指数
1
解决办法
71
查看次数

标签 统计

arguments ×1

blazor ×1

c# ×1

function ×1

gltf ×1

static-files ×1

three.js ×1