博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C# 结构(structure)
阅读量:2026 次
发布时间:2019-04-28

本文共 1365 字,大约阅读时间需要 4 分钟。

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication24{    public struct CoOrds    {        public int x, y;        public CoOrds(int p1, int p2)        {            x = p1;            y = p2;        }    }    class Program    {        static void Main(string[] args)        {            // Initialize:   使用构造函数初始化            CoOrds coords1 = new CoOrds();            CoOrds coords2 = new CoOrds(10, 10);            // Display results:            Console.Write("CoOrds 1: ");            Console.WriteLine("x = {0}, y = {1}", coords1.x, coords1.y);            Console.Write("CoOrds 2: ");            Console.WriteLine("x = {0}, y = {1}", coords2.x, coords2.y);            // Keep the console window open in debug mode.            Console.WriteLine("Press any key to exit.");            Console.ReadKey();            /*  结构可以不使用new关键字声明            // Declare an object:            CoOrds coords1;            // Initialize:            coords1.x = 10;            coords1.y = 20;            // Display results:            Console.Write("CoOrds 1: ");            Console.WriteLine("x = {0}, y = {1}", coords1.x, coords1.y);            // Keep the console window open in debug mode.            Console.WriteLine("Press any key to exit.");            Console.ReadKey();*/        }    }}

转载地址:http://otdaf.baihongyu.com/

你可能感兴趣的文章
试用实达Web终端
查看>>
VVSN.exe [进程知识库 发表于 2005-12-14 23:40:00]
查看>>
无法安装虚拟光驱的解决方法
查看>>
使用更流畅 手把手教你正确设置虚拟内存
查看>>
摒弃盗版,让我们拥有正版,给你最实用的软件。有效的优化
查看>>
你不能不知道的免费软件
查看>>
最近装了SQL Server 2005和Win2003R2的尤为注意/reginf.exe
查看>>
IT业界名词解释:刀片服务器
查看>>
多机共享上网完全手册
查看>>
关于TrackBack
查看>>
TrackBack技术规范+新手指南
查看>>
Apache优化配置
查看>>
vmware,qemu虚拟机网络设置
查看>>
QEMU-VMWARE的开源替代品
查看>>
qemu虚拟机
查看>>
新的 kqemu 1.3 比 VMware 快
查看>>
qemu虚拟机的安装体验
查看>>
开源世界的虚拟机 QEMU
查看>>
在虚拟机上调试网络时要注意的内容
查看>>
DOS网络启动盘
查看>>