Ala*_*an2 5 xamarin xamarin.forms
我刚刚更新了我的应用程序中的软件包,我收到了许多我不明白的新类型错误:
/Users/alan/Downloads/Japanese 31/Japanese/obj/Debug/Views/Help/GettingStarted.xaml.g.cs(51,51):
Error CS0542: 'GettingStarted': member names cannot be the same as their enclosing type (CS0542) (Japanese)
Run Code Online (Sandbox Code Playgroud)
我有XAML代码,看起来像这样;
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Japanese;assembly=Japanese"
x:Class="Japanese.GettingStarted"
x:Name="GettingStarted"
Title="Getting Started">
<ContentPage.Content>
Run Code Online (Sandbox Code Playgroud)
我的C#
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace Japanese
{
public partial class GettingStarted : ContentPage
{
public GettingStarted()
{
Run Code Online (Sandbox Code Playgroud)
我是否错误地编写了我的XAML和cs?我认为这是使用部分类和相同类名来实现此目的的方法.
Ger*_*uis 23
x:Name="GettingStarted"这就是问题.这将是您的页面的名称,但它也是该页面的类的名称.指定x:Name属性的值会在代码隐藏中创建具有该名称的变量.所以你得到的是:GettingStarted GettingStarted = new GettingStarted();至少可以说是令人困惑的.我猜Xamarin团队遇到了这些相同名称和类型的问题,并决定阻止它.
尝试使用不同的名称,或者,如果您不想使用不同的外壳,例如: x:Name="gettingStarted"
| 归档时间: |
|
| 查看次数: |
2706 次 |
| 最近记录: |