Structure instantiation, structure instance

Source: Internet
Author: User

Structure instantiation, structure instance

1 using System; 2 using System. collections. generic; 3 using System. linq; 4 using System. text; 5 6 namespace Test08 7 {8 class Program 9 {10 // public struct Round // define a circular structure 11 // {12 // public double r; // the radius of the circle is 13 //// <summary> 14 //// calculate the circular area by 15 //// </summary> 16 //// <returns> circular Area </returns> 17 // public double Area () 18 // {19 // return Math. PI * r; 20 //} 21 //} 22 // static void Main (string [] args) 23 // {24 // Round myRound; // instantiate the circular structure 25 // myRound. r = 5; // assign a value of 26 to the circle radius // Console. writeLine ("circular area:" + myRound. area (); 27 //} 28 public struct yuan 29 {30 public double r; 31 public double Area () 32 {33 return Math. PI * r; 34} 35} 36 public static void Main (string [] args) 37 {38 yuan mianji; // structure instantiation 39 mianji. r = 1; 40 Console. writeLine (mianji. area (); 41} 42} 43}

 

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.