FrameworkName.Equality(FrameworkName, FrameworkName) 操作员

定义

返回一个值,该值指示两个 FrameworkName 对象是否表示相同的 .NET 版本。

public:
 static bool operator ==(System::Runtime::Versioning::FrameworkName ^ left, System::Runtime::Versioning::FrameworkName ^ right);
public static bool operator == (System.Runtime.Versioning.FrameworkName left, System.Runtime.Versioning.FrameworkName right);
public static bool operator == (System.Runtime.Versioning.FrameworkName? left, System.Runtime.Versioning.FrameworkName? right);
static member ( = ) : System.Runtime.Versioning.FrameworkName * System.Runtime.Versioning.FrameworkName -> bool
Public Shared Operator == (left As FrameworkName, right As FrameworkName) As Boolean

参数

left
FrameworkName

要比较的第一个对象。

right
FrameworkName

要比较的第二个对象。

返回

如果 leftright 参数表示相同的 .NET Framework 版本,则为 true;否则为 false

示例

下面的示例使用相等运算符来确定表示 .NET 运行版本的 对象是否 FrameworkName 等于支持的 .NET 版本。 请注意,这两个版本不相等,因为它们的版本号不同。

FrameworkName supportedVer1 = new FrameworkName(".NET Framework, Version=4.0");
FrameworkName actualVersion = new FrameworkName(String.Format(
                                           ".NET Framework, Version={0}", 
                                           Environment.Version.ToString()));
                                           
Console.WriteLine("Supported Version: {0}", supportedVer1);
Console.WriteLine("Actual Version:    {0}", actualVersion);
if (supportedVer1 == actualVersion)    
   Console.WriteLine("The supported and actual Framework versions are the same.");
else
   Console.WriteLine("The supported and actual Framework versions are different.");

Console.WriteLine();
// The example displays the following output:
//       The supported and actual Framework versions are different.
Dim supportedVer1 As New FrameworkName(".NET Framework, Version=4.0")
Dim actualVersion As New FrameworkName(String.Format(".NET Framework, Version={0}", 
                                       Environment.Version.ToString())) 

Console.WriteLine("Supported Version: {0}", supportedVer1)
Console.WriteLine("Actual Version:    {0}", actualVersion)
If supportedVer1 = actualVersion Then
   Console.WriteLine("The supported and actual Framework versions are the same.")
Else
   Console.WriteLine("The supported and actual Framework versions are different.")
End If 
Console.WriteLine()
' The example displays the following output:
'      Supported Version: .NET Framework,Version=v4.0
'      Actual Version:    .NET Framework,Version=v4.0.30319.18010
'      The supported and actual Framework versions are different.

注解

方法 Equality 定义 对象的相等运算符的 FrameworkName 运算。

不支持自定义运算符的语言可以改为调用 FrameworkName.Equals(FrameworkName) 方法。

适用于