I just updated packages in my application and I am getting many new errors of this type that I don't understand:
/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)
I have XAML code that looks like this;
<?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>
My C#
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace Japanese
{
public partial class GettingStarted : ContentPage
{
public GettingStarted()
{
Am I coding my XAML and cs wrongly? I thought this is the way to do this with partial classes and the same class name.
x:Name="GettingStarted"
this is the problem. This will be the name of your page, but it is also the name of the class of that page. Specifying a value for the x:Name
attribute creates a variable with that name in your code-behind. So what you'll get is: GettingStarted GettingStarted = new GettingStarted();
This is confusing to say the least. I'm guessing the Xamarin team ran into a problem with these identical names and types and decided to block it.
Try coming up with a different name, or, if you don't want to use a different casing like: x:Name="gettingStarted"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With