码迷,mamicode.com
首页 > Windows程序 > 详细

.NET深入 c#数据类型2

时间:2016-04-06 22:58:24      阅读:275      评论:0      收藏:0      [点我收藏+]

标签:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SL1
{
    class Program
    {
        public struct Student
        {
            public int _id;
            public int _age;
            public void Show()
            {
                Console.WriteLine("ID:{0}\n年龄:{1}", _id, _age);
            }
        }
        static void Main(string[] args)
        {
            Student stu;
            stu._id = 1001;
            stu._age = 20;
            stu.Show();


            //int[] infozhang = new int[] { 170, 60 };
            //int[] infoLi = new int[2];
            //Console.WriteLine("复制前-----李明德身高为:" + infozhang[0] + "体重是:" + infoLi[1]);
            //for (int i = 0; i < infozhang.Length;i++ )
            //{
            //    infoLi[i] = infozhang[i];
            //}
            //Console.WriteLine("去年张浩的身高为:" + infozhang[0] + "体重是:" + infozhang[1] + ",李明的身高为:" + infoLi[0] + "体重是:" + infoLi[1]);
            //infoLi[0] = 180;
            //infoLi[1] = 70;
            //Console.WriteLine("今年张浩的身高为:" + infozhang[0] + "体重是:" + infozhang[1] + ",李明的身高为:" + infoLi[0] + "体重是:" + infoLi[1]);





            //int[] infozhang = new int[] { 170,60};
            //int[] infoLi = infozhang;
            //Console.WriteLine("去年张浩的身高为:"+infozhang [0]+"体重是:"+infozhang [1]+",李明的身高为:"+infoLi[0]+"体重是:"+infoLi[1]);
            //infoLi [0]=180;
            //infozhang[1] = 70;
            //Console.WriteLine("今年张浩的身高为:" + infozhang[0] + "体重是:" + infozhang[1] + ",李明的身高为:" + infoLi[0] + "体重是:" + infoLi[1]);


            //int heightZhang = 170;
            //int heightli = heightZhang;
            //Console.WriteLine("去年李明的身高为:"+heightli +"去年张浩的身高为:"+heightZhang);
            //heightli = 180;
            //Console.WriteLine("今年李明的身高为:" + heightli + "今年张浩的身高为:" + heightZhang);
            Console.ReadLine();

        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Student
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] points = new int[5];
            int[] newpoints = new int[5];
            Console.WriteLine("请输入5位会员的积分");
            for (int i = 0; i < points.Length; i++)
            {
                Console.Write("" + (i + 1) + "位会员积分:");
                points[i] = Convert.ToInt32(Console.ReadLine());
            }
            for (int i = 0; i < points.Length; i++)
            {
                newpoints[i] = points[i];
                newpoints[i] = newpoints[i] + 500;
            }
            Console.WriteLine("\n序号  历史积分  新年积分");
            //省略代码循环输出两个年度的积分
            for (int i = 0; i < points.Length;i++ )
            {
                Console.WriteLine("{0}\t{1}\t{2}",(i+1),points[i] ,newpoints[i]);
            }
            Console.ReadLine();

            //int i = 123;
            //object o = i;
            //i = 456;

            //int i = 123;
            //object o = i;
            //int j=(int)o;
            //Console.WriteLine("值类型的值为:{0}",i);
            //Console.WriteLine("引用类型的值为:{0}",j);
            //Console.ReadLine();

        }
    }
}

 

.NET深入 c#数据类型2

标签:

原文地址:http://www.cnblogs.com/WuXuanKun/p/5317161.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!