using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace day01{ class PRogram { static void Main(string[] args) { Console.WriteLine("一"); int heightZhang = 170;//张浩的身高 int heightLi = heightZhang;//李明的身高 Console.WriteLine("去年--张浩的身高是:"+heightZhang+",李明的身高是:"+heightLi); //今年的变化 heightLi = 180; Console.WriteLine("今年--张浩的身高是:" + heightZhang + ",李明的身高是:" + heightLi); Console.WriteLine("二"); int [] infozhang = new int[] { 170, 60 };//张浩的身高和体重信息 int[] infoli = infozhang; //李明的身高和体重 Console.WriteLine("去年--张浩的身高:"+infozhang[0]+"体重是:"+ infozhang[1]+",李明的身高是:"+ infoli[0]+"体重是:"+infoli[1]); infoli[0] = 180;//今年李明的身高变为180 infoli[1] = 70;//今年李明的体重变为70 Console.WriteLine("今年--张浩的身高:" + infozhang[0] + "体重是:" + infozhang[1] + ",李明的身高是:" + infoli[0] + "体重是:" + infoli[1]); Console.WriteLine("三"); int[] zhang = new int[] { 170, 60 };//张浩的身高和体重信息 int [] li = new int[2]; Console.WriteLine("复制前--李明的身高是:"+li[0]+"体重是:"+li[1]); //数组复制 for (int i = 0; i < zhang.Length; i++) { li[i] = zhang[i]; } Console.WriteLine("去年--张浩的身高是"+zhang[0]+"体重是:"+zhang[1]+",李明的身高是:" +li[0]+"李明的体重是:"+li[1]); li[0] = 180;//今年李明的身高 li[1] = 70;//今年李明的体重 Console.WriteLine("今年--张浩的身高是" + zhang[0] + "体重是:" + zhang[1] + ",李明的身高是:" + li[0] + "李明的体重是:" + li[1]);Console.WriteLine("五"); student stu; stu.id = 10086; stu.age = 17; stu.name = "梦梦"; stu.show(); Console.ReadLine(); } }}Student 类 (调用)using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace day01{ public struct student { public int id;//ID public int age;//年龄 public string name;//名字 public void show() { Console.WriteLine("Id:{0}/n年龄:{1}/n名字:{2}",id,age,name); } }}
新闻热点
疑难解答