C# interface type

PHPz
Release: 2023-09-18 17:17:02
forward
1390 people have browsed it

C# 接口类型

Interface defines properties, methods and events, which are members of the interface. An interface only contains declarations of members.

Some interface types in C# include.

  • IEnumerable - The basic interface for all common collections.

  • #IList > - Generic interface implemented by array and list types.

  • IDictionary - Collection of dictionaries.

  • IEnumerable is an interface that defines a single method GetEnumerator, which returns the IEnumerator interface.

    This applies to read-only access to collections that implement IEnumerable, which can be used with a foreach statement.

    This applies to read-only access to the collection. p>

    The following shows the implementation of the IEnumerable interface.

    Example

    class Demo : IEnumerable, IEnumerator {
       // IEnumerable method GetEnumerator()
       IEnumerator IEnumerable.GetEnumerator() {
          throw new NotImplementedException();
       }
       public object Current {
          get { throw new NotImplementedException(); }
       }
       // IEnumertor method
       public bool MoveNext() {
          throw new NotImplementedException();
       }
       // IEnumertor method
       public void Reset() {
          throw new NotImplementedException();
       }
    }
    Copy after login

    Above you can see the two methods of IEnumerator.

    // IEnumerator method
    public bool MoveNext() {
       throw new NotImplementedException();
    }
    // IEnumertor method
    public void Reset() {
       throw new NotImplementedException();
    }
    Copy after login

    The above is the detailed content of C# interface type. For more information, please follow other related articles on the PHP Chinese website!

    source:tutorialspoint.com
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!