Editare

Partajați prin


FrameworkName.Inequality(FrameworkName, FrameworkName) Operator

Definition

Returns a value that indicates whether two FrameworkName objects represent different .NET 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);
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

Parameters

left
FrameworkName

The first object to compare.

right
FrameworkName

The second object to compare.

Returns

true if the left and right parameters represent different .NET versions; otherwise, false.

Examples

The following example uses the equality operator to determine whether a FrameworkName object that represents the running version of .NET is equal to a supported version of .NET. 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.

Remarks

The Inequality method defines the operation of the inequality operator for FrameworkName objects.

Languages that do not support custom operators can test for inequality by calling the FrameworkName.Equals(FrameworkName) method and reversing its value.

Applies to