type.equals是啥意思?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了type.equals是啥意思?相关的知识,希望对你有一定的参考价值。

type.equals
在JSP中是什么意思?
有什么用法?

Type..::.Equals 方法 (Type)确定当前 Type 的基础系统类型是否与指定 Type 的基础系统类型相同。

命名空间: System
程序集: mscorlib(在 mscorlib.dll 中)
语法
Visual Basic(声明) Public Function Equals ( _
o As Type _
) As BooleanVisual Basic (用法) Dim instance As Type
Dim o As Type
Dim returnValue As Boolean

returnValue = instance.Equals(o)C# public bool Equals(
Type o
)参数
o
类型:System..::.Type
Type,其基础系统类型将与当前 Type 的基础系统类型相比较。

返回值
类型:System..::.Boolean
如果 o 的基础系统类型与当前 Type 的基础系统类型相同,则为 true;否则为 false。

示例
下面的示例使用 Equals 比较两个类型。

说明:
若要运行此示例,请参见生成使用 Demo 方法和 TextBlock 控件的示例。

Visual Basic 复制代码 Imports System.Reflection

Class Example

Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)

Dim a As Type = GetType(System.String)
Dim b As Type = GetType(System.Int32)

outputBlock.Text += String.Format("0 = 1: 2", a, b, a.Equals(b)) & vbCrLf
' The Type objects in a and b are not equal,
' because they represent different types.

a = GetType(Example)
b = New Example().GetType()
outputBlock.Text += String.Format("0 is equal to 1: 2", a, b, a.Equals(b)) & vbCrLf
' The Type objects in a and b are equal,
' because they both represent type Example.

b = GetType(Type)
outputBlock.Text += String.Format("typeof(0).Equals(typeof(1)): 2", a, b, a.Equals(b)) & vbCrLf
' The Type objects in a and b are not equal,
' because variable a represents type Example
' and variable b represents type Type.

'Console.ReadLine()

End Sub
End Class
'
' This code example produces the following output:
' System.String = System.Int32: False
' Example is equal to Example: True
' typeof(Example).Equals(typeof(System.Type)): False
'
C# 复制代码
using System;
using System.Reflection;

class Example

public static void Demo(System.Windows.Controls.TextBlock outputBlock)


Type a = typeof(System.String);
Type b = typeof(System.Int32);

outputBlock.Text += String.Format("0 == 1: 2", a, b, a.Equals(b)) + "\n";

// The Type objects in a and b are not equal,
// because they represent different types.

a = typeof(Example);
b = new Example().GetType();

outputBlock.Text += String.Format("0 is equal to 1: 2", a, b, a.Equals(b)) + "\n";

// The Type objects in a and b are equal,
// because they both represent type Example.

b = typeof(Type);

outputBlock.Text += String.Format("typeof(0).Equals(typeof(1)): 2", a, b, a.Equals(b)) + "\n";

// The Type objects in a and b are not equal,
// because variable a represents type Example
// and variable b represents type Type.

//Console.ReadLine();




//
/* This code example produces the following output:
System.String == System.Int32: False
Example is equal to Example: True
typeof(Example).Equals(typeof(System.Type)): False
*/
参考技术A 比较两个对象是否相等

以上是关于type.equals是啥意思?的主要内容,如果未能解决你的问题,请参考以下文章

.equals()到底是啥意思?

one.pound,equal是啥意思

equal中文是啥意思

"".equals--双引号的equals是啥意思?跪求解释

请问各位大佬这道java的重写equals和重写hashcode方法内部是啥意思呀?

在C#.NET中 sender.Equals 表示的是啥?