The interface in C # declares a property, but there is no attribute in the hint "interface".

Source: Internet
Author: User

The interface definition properties in C # are as follows:

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 6 namespacech08ex057 {8     Abstract  classHotdrink9    {Ten       floatMilk; One       floatSugar; A       -        Public intDrink (intx); -        Public intAddmilk (intx); the        Public intAddsugar (intx);  -  -    }     -  +       Public InterfaceIcup -   { +       intColor; A       intVolume; at       intRefill (intx); -       BOOLWash (); -  -    } -      classCupofcoffee:hotdrink,icup -     { in         intBeantype; -          to          Public intDrink (intx) +         { -Console.WriteLine ("Welcome,drink a cup of Coffee?? \ n"); the            *             returnx; $         }Panax Notoginseng  -       ... ... the } +  A  classCupoftea:hotdrink,icup the     { +         intLeaftype; -          $          Public intDrink (intx) $         { -Console.WriteLine ("Welcome,drink a cup of Tea?? \ n"); -            the             returnx; -         }Wuyi  the       ... ... - } Wu  -     class Program About   { $       Static voidMain (string[] args) -       { -  -Cupofcoffee coffee=NewCupofcoffee (); ACoffee.drink (2); +          ... the  -       } $  the  the  the   } the  -  in}

The above code hints error:

Lines 21st and 22nd,Interfaces cannot contain fields.

The interface in C # declares a property, but there is no attribute in the hint "interface".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.