Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Error 1 The modifier 'abstract' is not valid for this item

Error 1 The modifier 'abstract' is not valid for this item

Scheduled Pinned Locked Moved C#
csharpgraphicshelp
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RaoulICT
    wrote on last edited by
    #1

    I'm trying to build my C# project, I get the error: The modifier 'abstract' is not valid for this item Is the item: FieldChanged; In the following Interface:

    namespace program.Drawing.Fields
    {
    using System;
    using System.Collections.Generic;
    using System.Runtime.CompilerServices;

    public interface IFieldHolder
    {
    

    abstract event FieldChangedEventHandler FieldChanged;

    void AddField(Field field);
    Field GetField(FieldType fieldType);
    List GetFields();
    bool HasField(FieldType fieldType);
    void RemoveField(Field field);
    void SetFieldValue(FieldType fieldType, object value);
    }
    }

    T B 2 Replies Last reply
    0
    • R RaoulICT

      I'm trying to build my C# project, I get the error: The modifier 'abstract' is not valid for this item Is the item: FieldChanged; In the following Interface:

      namespace program.Drawing.Fields
      {
      using System;
      using System.Collections.Generic;
      using System.Runtime.CompilerServices;

      public interface IFieldHolder
      {
      

      abstract event FieldChangedEventHandler FieldChanged;

      void AddField(Field field);
      Field GetField(FieldType fieldType);
      List GetFields();
      bool HasField(FieldType fieldType);
      void RemoveField(Field field);
      void SetFieldValue(FieldType fieldType, object value);
      }
      }

      T Offline
      T Offline
      Trak4Net
      wrote on last edited by
      #2

      Have a read at the link below

      Quote:

      •Abstract method declarations are only permitted in abstract classes.

      Quote:

      Interfaces and interface members are abstract;

      http://msdn.microsoft.com/en-us/library/sf985hc5(v=vs.71).aspx[^] and here http://msdn.microsoft.com/en-us/library/ms173156.aspx[^]

      R 1 Reply Last reply
      0
      • T Trak4Net

        Have a read at the link below

        Quote:

        •Abstract method declarations are only permitted in abstract classes.

        Quote:

        Interfaces and interface members are abstract;

        http://msdn.microsoft.com/en-us/library/sf985hc5(v=vs.71).aspx[^] and here http://msdn.microsoft.com/en-us/library/ms173156.aspx[^]

        R Offline
        R Offline
        RaoulICT
        wrote on last edited by
        #3

        Can you gave me a fix in my code

        T 1 Reply Last reply
        0
        • R RaoulICT

          Can you gave me a fix in my code

          T Offline
          T Offline
          Trak4Net
          wrote on last edited by
          #4

          You just need to remove the abstract declaration for the event.

          namespace program.Drawing.Fields
          {
          using System;
          using System.Collections.Generic;
          using System.Runtime.CompilerServices;

          public interface IFieldHolder
          {
            event FieldChangedEventHandler FieldChanged;
          
            void AddField(Field field);
            Field GetField(FieldType fieldType);
            List<Field> GetFields();
            bool HasField(FieldType fieldType);
            void RemoveField(Field field);
            void SetFieldValue(FieldType fieldType, object value);
          }
          

          }

          1 Reply Last reply
          0
          • R RaoulICT

            I'm trying to build my C# project, I get the error: The modifier 'abstract' is not valid for this item Is the item: FieldChanged; In the following Interface:

            namespace program.Drawing.Fields
            {
            using System;
            using System.Collections.Generic;
            using System.Runtime.CompilerServices;

            public interface IFieldHolder
            {
            

            abstract event FieldChangedEventHandler FieldChanged;

            void AddField(Field field);
            Field GetField(FieldType fieldType);
            List GetFields();
            bool HasField(FieldType fieldType);
            void RemoveField(Field field);
            void SetFieldValue(FieldType fieldType, object value);
            }
            }

            B Offline
            B Offline
            BobJanova
            wrote on last edited by
            #5

            Just to expand slightly on the (correct) fix already posted: You can't put 'public' or 'abstract' on interface members, because by definition they are already public and abstract, so to prevent confusion* no access modifiers are permitted. *: or that's what the rationale is, anyway. I think it's silly, it prevents future expansion and the fact that the default scope (public abstract) in an interface is different from that (private) in a class is more confusing than making you write 'public abstract' on things in interfaces.

            P 1 Reply Last reply
            0
            • B BobJanova

              Just to expand slightly on the (correct) fix already posted: You can't put 'public' or 'abstract' on interface members, because by definition they are already public and abstract, so to prevent confusion* no access modifiers are permitted. *: or that's what the rationale is, anyway. I think it's silly, it prevents future expansion and the fact that the default scope (public abstract) in an interface is different from that (private) in a class is more confusing than making you write 'public abstract' on things in interfaces.

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              I think it makes sense that everything in an Interface is public and abstract by definition, but I don't like default modifiers on class members.

              L 1 Reply Last reply
              0
              • P PIEBALDconsult

                I think it makes sense that everything in an Interface is public and abstract by definition, but I don't like default modifiers on class members.

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                :thumbsup:

                Luc Pattyn [My Articles] Nil Volentibus Arduum

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups