笔记3
using System;
using System.Collections.Generic;
using System.Text;
namespace List_Value_Types
{
class Program
{
static void Main(string[] args)
{
SByte a = 0;
Byte b = 0;
Int16 c = 0;
Int32 d = 0;
Int64 e = 0;
string s = "";
Exception ex = new Exception();
object[] types = { a, b, c, d, e, s, ex };
foreach ( object o in types )
{
string type;
if (o.GetType().IsValueType)
type = "Value type";
else
type = "Reference Type";
Console.WriteLine("{0}: {1}", o.GetType(), type );
}
Console.ReadKey();
}
}
}
/* 打印
System.SByte: Value type
System.Byte: Value type
System.Int16: Value type
System.Int32: Value type
System.Int64: Value type
System.String: Reference Type
System.Exception: Reference Type
*/
using System.Collections.Generic;
using System.Text;
namespace List_Value_Types
{
class Program
{
static void Main(string[] args)
{
SByte a = 0;
Byte b = 0;
Int16 c = 0;
Int32 d = 0;
Int64 e = 0;
string s = "";
Exception ex = new Exception();
object[] types = { a, b, c, d, e, s, ex };
foreach ( object o in types )
{
string type;
if (o.GetType().IsValueType)
type = "Value type";
else
type = "Reference Type";
Console.WriteLine("{0}: {1}", o.GetType(), type );
}
Console.ReadKey();
}
}
}
/* 打印
System.SByte: Value type
System.Byte: Value type
System.Int16: Value type
System.Int32: Value type
System.Int64: Value type
System.String: Reference Type
System.Exception: Reference Type
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace SortString
{
class Program
{
static void Main(string[] args)
{
string s = "Microsoft .NET Framework 2.0 Application Development Foundation";
string[] sa = s.Split(' ');
Array.Sort(sa);
s = string.Join(" ", sa);
Console.WriteLine(s);
//打印 .NET 2.0 Application Development Foundation Framework Microsoft
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Text;
namespace SortString
{
class Program
{
static void Main(string[] args)
{
string s = "Microsoft .NET Framework 2.0 Application Development Foundation";
string[] sa = s.Split(' ');
Array.Sort(sa);
s = string.Join(" ", sa);
Console.WriteLine(s);
//打印 .NET 2.0 Application Development Foundation Framework Microsoft
Console.ReadKey();
}
}
}

浙公网安备 33010602011771号