复杂的变量类型:枚举结构数组(例子)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了复杂的变量类型:枚举结构数组(例子)相关的知识,希望对你有一定的参考价值。
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication4 { enum orientation : byte { 北=1, 南=2, 东=3, 西=4 } struct route { public orientation direction; public double distance; } class Program { static void Main(string[] args) { route myRoute; int myDirection; double myDistance; Console.WriteLine(" 1>北 \n 2>南 \n 3>东 \n 4>西"); do { Console.WriteLine("select a direction:"); myDirection = Convert.ToInt32(Console.ReadLine()); } while ((myDirection<1||myDirection>4)); Console.WriteLine("input a distance:"); myDistance = Convert.ToDouble(Console.ReadLine()); myRoute.direction = (orientation)myDirection; myRoute.distance = myDistance; Console.WriteLine("my specifies a diretion of {0} and a " + "distance of {1}", myRoute.direction, myRoute.distance); Console.ReadKey(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication5 { class Program { static void Main(string[] args) { string[] friendNames = { "yaobao", "beijing", "meinv" }; Console.WriteLine("here are {0} of my friend:", friendNames.Length); for (int i = 0; i < friendNames.Length; i++) { Console.WriteLine(friendNames[i]); } Console.ReadKey(); } } }
以上是关于复杂的变量类型:枚举结构数组(例子)的主要内容,如果未能解决你的问题,请参考以下文章