FrameworkName.Inequality(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 op_Inequality : 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 版本,则为 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 different.");
else
   Console.WriteLine("The supported and actual Framework versions are the same.");

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 different.")
Else
   Console.WriteLine("The supported and actual Framework versions are the same.")
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.

注解

方法 Inequality 定义 对象的不相等运算符的操作 FrameworkName

不支持自定义运算符的语言可以通过调用 FrameworkName.Equals(FrameworkName) 方法并反转其值来测试不相等性。

适用于