PropertyDataCollection.Item[String] Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the specified property from the PropertyDataCollection, using [] syntax. This property is the indexer for the PropertyDataCollection class.
public:
virtual property System::Management::PropertyData ^ default[System::String ^] { System::Management::PropertyData ^ get(System::String ^ propertyName); };
public virtual System.Management.PropertyData this[string propertyName] { get; }
member this.Item(string) : System.Management.PropertyData
Default Public Overridable ReadOnly Property Item(propertyName As String) As PropertyData
Parameters
- propertyName
- String
The name of the property to retrieve.
Property Value
Returns a PropertyData containing the data for a specified property in the collection.
Examples
The following example gets the Freespace property from a ManagementClass.
using System;
using System.Management;
public class Sample
{
public static void Main(string[] args)
{
ManagementObject m = new ManagementObject(
"Win32_LogicalDisk.DeviceID=\"C:\"");
Console.WriteLine("Free space on drive C is: " +
m.Properties["Freespace"].Value + " bytes");
}
}
Imports System.Management
Class Sample_ManagementClass
Public Overloads Shared Function Main( _
ByVal args() As String) As Integer
Dim m As New ManagementObject( _
"Win32_LogicalDisk.DeviceID=""C:""")
Console.WriteLine( _
m.Properties("FreeSpace").Value)
Return 0
End Function
End Class
Remarks
Property Value
A PropertyData, based on the name specified.
.NET Framework Security
Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
Applies to
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈