共用方式為


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) 方法來測試是否不相等,並反轉其值。

適用於