共用方式為


Control.ProductVersion 屬性

定義

取得包含控制項的組裝版本。

public:
 property System::String ^ ProductVersion { System::String ^ get(); };
[System.ComponentModel.Browsable(false)]
public string ProductVersion { get; }
[<System.ComponentModel.Browsable(false)>]
member this.ProductVersion : string
Public ReadOnly Property ProductVersion As String

屬性值

包含控制項的組裝檔案版本。

屬性

範例

以下程式碼範例顯示應用程式在 中 Label 包含 Form的資訊。 此範例要求 CompanyNameProductNameProductVersion 已被設定。

void AboutDialog_Load( Object^ /*sender*/, EventArgs^ /*e*/ )
{
   // Display the application information in the label.
   this->labelVersionInfo->Text = String::Format(  "{0} {1} Version: {2}", this->CompanyName, this->ProductName, this->ProductVersion );
}
private void AboutDialog_Load(object sender, EventArgs e)
{
   // Display the application information in the label.
   this.labelVersionInfo.Text = 
      this.CompanyName + "  " + 
      this.ProductName + "  Version: " +
      this.ProductVersion;  
}
Private Sub AboutDialog_Load(sender As Object, e As EventArgs) Handles MyBase.Load
   ' Display the application information in the label.
   Me.labelVersionInfo.Text = _
      Me.CompanyName + "  " + _
      Me.ProductName + "  Version: " + _
      Me.ProductVersion
   End Sub

備註

ProductVersion 屬性為唯讀屬性。 要改變此性質的值,請設定 的性質值AssemblyVersionAttributeVersion 以下一行 C# 程式碼設定屬性 ProductVersion

[assembly: AssemblyVersion("1.0.1")]

備註

強烈建議您提供公司名稱、產品名稱及產品版本。 提供這些資訊使得 Windows 表單 Application.UserAppDataPath 功能得以使用,例如讓撰寫符合「Windows認證」計畫的應用程式變得更容易。

適用於

另請參閱