[英]How to fix : CS0161 'MauiProgram.CreateMauiApp()': not all code paths return a value?
How to fix this:如何解决这个问题:
CS0161 'MauiProgram.CreateMauiApp()': not all code paths return a value
CS0161“MauiProgram.CreateMauiApp()”:并非所有代码路径都返回值
I dont see what i'm doing wrong, can you please assist?我不明白我做错了什么,你能帮忙吗? Thank you!
谢谢!
PS: Im on realy begining level so Im sorry if I didnt seen solution that can be very simple but Im to stupid right now to solve it by myself. PS:我真的处于入门水平,所以如果我没有看到非常简单的解决方案,我很抱歉,但我现在很愚蠢,无法自己解决。
namespace LoginApp;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
}
}
I was searching on other forums etc. but I didint found answear for my porblem.我在其他论坛等上搜索,但我没有找到我的问题的答案。
in C# if a method has a non-void return type it means that the method must return an instance of that type.在 C# 中,如果方法具有非 void返回类型,则意味着该方法必须返回该类型的实例。
Which in this case:在这种情况下:
public static MauiApp CreateMauiApp()
It is of type MauiApp
.它是
MauiApp
类型。 If you look at the default CreateMauiApp
method created by the template, the last line is如果您查看模板创建的默认
CreateMauiApp
方法,最后一行是
return builder.Build();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.