using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleHelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("=> Array of Objects.");
//对象数组可以是任何东西
object[] myObjects = new object[4];
myObjects[0] = 10;
myObjects[1] = false;
myObjects[2] = new DateTime(1969, 3, 24);
myObjects[3] = "Form & Void";
foreach (var item in myObjects)
{
//输出数组中每一项的类型和值
Console.WriteLine("Type: {0},Value: {1}",item.GetType(),item);
}
Console.ReadLine();
}
private static void Swap(ref int x,ref int y)
{
int temp = x;
x = y;
y = temp;
}
}
}
C#的对象数组
最新推荐文章于 2024-07-12 19:36:12 发布