FrameworkName 建構函式

定義

初始化 FrameworkName 類別的新執行個體。Initializes a new instance of the FrameworkName class.

多載

FrameworkName(String)

從包含 .NET 版本資訊的字串,初始化 FrameworkName 類別的新執行個體。Initializes a new instance of the FrameworkName class from a string that contains information about a version of .NET.

FrameworkName(String, Version)

從識別 .NET 版本的字串與 FrameworkName 物件,初始化 Version 類別的新執行個體。Initializes a new instance of the FrameworkName class from a string and a Version object that identify a .NET version.

FrameworkName(String, Version, String)

從字串、識別 .NET 版本的 FrameworkName 物件,以及設定檔名稱,初始化 Version 類別的新執行個體。Initializes a new instance of the FrameworkName class from a string, a Version object that identifies a .NET version, and a profile name.

FrameworkName(String)

從包含 .NET 版本資訊的字串,初始化 FrameworkName 類別的新執行個體。Initializes a new instance of the FrameworkName class from a string that contains information about a version of .NET.

public:
 FrameworkName(System::String ^ frameworkName);
public FrameworkName (string frameworkName);
new System.Runtime.Versioning.FrameworkName : string -> System.Runtime.Versioning.FrameworkName
Public Sub New (frameworkName As String)

參數

frameworkName
String

包含 .NET Framework 版本資訊的字串。A string that contains .NET Framework version information.

例外狀況

frameworkNameEmptyframeworkName is Empty.

-或--or- frameworkName 具有兩個以下的元件或三個以上的元件。frameworkName has fewer than two components or more than three components.

-或--or- frameworkName 不包含主要和次要版本號碼。frameworkName does not include a major and minor version number.

-或--or- frameworkName 不包含有效的版本號碼。frameworkName does not include a valid version number.

frameworkNamenullframeworkName is null.

備註

此函式會使用 FrameworkName(String) 下列格式來剖析字串。The FrameworkName(String) constructor parses a string in the following format.

identifier,Version =VersionNumber[,Profile =profileName]identifier, Version=versionNumber[, Profile=profileName]

方括弧中的元件是選擇性的。Components in square brackets are optional. 下表說明每個元件。The following table describes each component.

元件Component 描述Description
identifieridentifier 識別這個實例的任一字元串 FrameworkNameAn arbitrary string that identifies this FrameworkName instance.
versionNumberversionNumber 表示 .NET 版本的字串,其格式為 [v]主要次要[.build修訂],其中 "v" 可以是大寫或小寫,而括弧代表版本號碼的選擇性元素。A string that represents the version of .NET, in the form [v]major.minor[.build.revision], where "v" can be either uppercase or lowercase, and the brackets denote optional elements of a version number.
profileNameprofileName 代表 .NET 版本設定檔的任一字元串。An arbitrary string that represents the profile of the .NET version. 通常,它是用來表示 .NET Framework 的一部分,例如 .NET Compact Framework 或 Silverlight。Typically, it is used to denote some subset of the .NET Framework, such as the .NET Compact Framework or Silverlight.

如果 versionNumberprofileName 都存在,則它們可以在 識別碼 之後以任何順序出現。If both versionNumber and profileName are present, they can appear in any order after identifier. 這些字串是由「版本」和「設定檔」關鍵字所定義,這些關鍵字不區分大小寫。These strings are defined by the "Version" and "Profile" keywords, which are not case-sensitive.

IdentifierversionNumberprofileName 元件的值會定義此物件屬性的值,如下所示 FrameworkNameThe values of the identifier, versionNumber, and profileName components define the values of this FrameworkName object's properties as follows:

  • 會移除 識別碼 元件中的任何前置或尾端空白字元,並將產生的字串指派給 Identifier 屬性。Any leading or trailing white space in the identifier component is removed and the resulting string is assigned to the Identifier property.

  • 從移除任何開頭或尾端的空白字元,以及初始的 "v" 或 "V" (如果有的話) versionNumberAny leading or trailing white space and the initial "v" or "V", if present, are removed from the versionNumber. 傳回的字串接著會傳遞至函式 Version.Version(String) ,並將產生的 System.Version 物件指派給 Version 屬性。The returned string is then passed to the Version.Version(String) constructor, and the resulting System.Version object is assigned to the Version property.

  • 移除元件中的任何前置或尾端空白字元 profileName ,並將產生的字串指派給 Profile 屬性。Any leading or trailing white space in the profileName component is removed and the resulting string is assigned to the Profile property.

以下是可傳遞給函式的有效字串範例 FrameworkNameThe following are examples of valid strings that can be passed to the FrameworkName constructor:

  • .NET Framework,Version = 4。0.NET Framework, Version=4.0

  • ..Netframework,Version = 4。0.NETFramework, Version=4.0

  • .NET Framework,Version = 2.0,Profile = Compact.NET Framework, Version=2.0, Profile=Compact

  • .NET Framework,Version = v4.0,Profile = Compact.NET Framework, Version=v4.0, Profile=Compact

  • .NET Framework,Profile = Full,Version = 2.0。0.NET Framework, Profile=Full, Version=2.0.0

適用於

FrameworkName(String, Version)

從識別 .NET 版本的字串與 FrameworkName 物件,初始化 Version 類別的新執行個體。Initializes a new instance of the FrameworkName class from a string and a Version object that identify a .NET version.

public:
 FrameworkName(System::String ^ identifier, Version ^ version);
public FrameworkName (string identifier, Version version);
new System.Runtime.Versioning.FrameworkName : string * Version -> System.Runtime.Versioning.FrameworkName
Public Sub New (identifier As String, version As Version)

參數

identifier
String

識別 .NET Framework 版本的字串。A string that identifies a .NET Framework version.

version
Version

包含 .NET Framework 版本資訊的物件。An object that contains .NET Framework version information.

例外狀況

identifierEmptyidentifier is Empty.

identifiernullidentifier is null.

-或--or- versionnullversion is null.

備註

FrameworkName類別需要 Version 物件至少包含主要和次要版本號碼。The FrameworkName class requires that a Version object include at least a major and minor version number.

適用於

FrameworkName(String, Version, String)

從字串、識別 .NET 版本的 FrameworkName 物件,以及設定檔名稱,初始化 Version 類別的新執行個體。Initializes a new instance of the FrameworkName class from a string, a Version object that identifies a .NET version, and a profile name.

public:
 FrameworkName(System::String ^ identifier, Version ^ version, System::String ^ profile);
public FrameworkName (string identifier, Version version, string profile);
public FrameworkName (string identifier, Version version, string? profile);
new System.Runtime.Versioning.FrameworkName : string * Version * string -> System.Runtime.Versioning.FrameworkName
Public Sub New (identifier As String, version As Version, profile As String)

參數

identifier
String

識別 .NET Framework 版本的字串。A string that identifies a .NET Framework version.

version
Version

包含 .NET Framework 版本資訊的物件。An object that contains .NET Framework version information.

profile
String

設定檔名稱。A profile name.

例外狀況

identifierEmptyidentifier is Empty.

identifiernullidentifier is null.

-或--or- versionnullversion is null.

備註

FrameworkName類別需要 Version 物件至少包含主要和次要版本號碼。The FrameworkName class requires that a Version object include at least a major and minor version number.

適用於