FrameworkName.Inequality(FrameworkName, FrameworkName) 运算符

定义

返回一个值,该值指示两个 FrameworkName 对象是否表示不同的 .NET Framework 版本。Returns a value that indicates whether two FrameworkName objects represent different .NET Framework versions.

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

要比较的第一个对象。The first object to compare.

right
FrameworkName

要比较的第二个对象。The second object to compare.

返回

如果 trueleft 参数表示不同的 .NET Framework 版本,则为 right;否则为 falsetrue if the left and right parameters represent different .NET Framework versions; otherwise, false.

示例

下面的示例使用相等运算符来确定表示 .NET Framework 运行版本的 FrameworkName 对象是否等于 .NET Framework 的受支持版本。The following example uses the equality operator to determine whether a FrameworkName object that represents the running version of the .NET Framework is equal to a supported version of the .NET Framework. 请注意,这两个版本不相等,因为它们不具有相同的版本号。Note that the two versions are not equal because they do not have identical version numbers.

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 对象的不相等运算符的运算。The Inequality method defines the operation of the inequality operator for FrameworkName objects.

不支持自定义运算符的语言可以通过调用 FrameworkName.Equals(FrameworkName) 方法并反转其值来测试是否不相等。Languages that do not support custom operators can test for inequality by calling the FrameworkName.Equals(FrameworkName) method and reversing its value.

适用于