Skip to content

Compiler Error CS0525 #46583

Open
Open
@teddga

Description

@teddga

Type of issue

Other (describe below)

Description

I wrote a stupid Interface, admittedly. My basic idea was to create an IType, IObject and and IEncoding. The intent was to mimic C# class, object and reader/writer. My thoughts were basically to create a simplistic framework of CSharp classes and such.

Here is my problem: "Compiler Error CS0525". It correctly describes the fact that I attempted to create a "field" in my interface.... and claims that this is illegal in CSharp. I don't disagree. I was imagining my own interpretation of how the world works. CSharp has it's own rules and regulations about such thing. I'm happy to agree with CSharp. But.... maybe a hint about how to implement my own needs? I don't care if "string Name" is technically illegal in an interface, but... Exactly why is it Illegal? and exactly why can't I implement a CSharp equivalent ?

The Documentation for CS0525 does not hint at a solution. It does not suggest protentional queries. It just says, "NO YOU CAN'T". But I want to know how to take care of my buisiness. right?

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/misc/cs0525?f1url=%3FappId%3Droslyn%26k%3Dk(CS0525)

Content source URL

https://github.com/dotnet/docs/blob/main/docs/csharp/misc/cs0525.md

Document Version Independent Id

5cc1abe5-2ab2-7159-f4ca-b2167d8bd719

Platform Id

1f400fa8-d039-c3f2-55db-241f514630ef

Article author

@BillWagner

Metadata

  • ID: a0cc20d7-1b1d-ab13-dcba-c1c3f3a530bd
  • PlatformId: 1f400fa8-d039-c3f2-55db-241f514630ef
  • Service: dotnet-csharp
  • Sub-service: errors-warnings

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions