⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1.5.txt

📁 《Microsoft Visual C# .NET 2003开发技巧大全》源代码
💻 TXT
字号:
Listing 1.5 Using Relational Operators on Value and Reference Types
using System;
namespace _10_Relations
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class ComparingRelations
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
// compare 2 values for equality
int a = 12;
int b = 12;
Console.WriteLine( a == b );
Console.WriteLine( (object)a == (object)b );
// compare 2 objects which contains overloaded == operator
string c = “hello”;
string d = “hello”;
Console.WriteLine( (object) c==(object) d );
// compare 2 objects for equality
ClassCompare x = new ClassCompare();
ClassCompare y;
x.val = 1;
y = x;
Console.WriteLine( x == y );
// changing 1 object also changes the other
x.val = 2;
Console.WriteLine( y.val.ToString() );
}
}
class ClassCompare
{
public int val = 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -