Export (0) Print
Expand All

ManagementClass.GetRelationshipClasses Method ()

Retrieves relationship classes that relate the class to others.

Namespace: System.Management
Assembly: System.Management (in system.management.dll)

public ManagementObjectCollection GetRelationshipClasses ()
public ManagementObjectCollection GetRelationshipClasses ()
public function GetRelationshipClasses () : ManagementObjectCollection
Not applicable.

Return Value

A collection of association classes that relate the class to any other class.

.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.

The following example uses the GetRelationshipClasses method to list the relationship classes to the CIM_LogicalDisk class. For more information, see "CIM_LogicalDisk" in the Windows Management Instrumentation documentation in the MSDN Library at http://msdn.microsoft.com/library.

using System;
using System.Management;

public class Sample
{
    public static void Main() 
    {
        ManagementClass c =
            new ManagementClass("CIM_LogicalDisk");

        foreach (ManagementClass r in c.GetSubclasses())
        {
            Console.WriteLine(
                "Instances of {0} are sub-classes",
                r["__CLASS"]);
        }
        
        foreach (ManagementClass r in c.GetRelationshipClasses())
        {
            Console.WriteLine(
                "{0} is a relationship class to " +
                c.ClassPath.ClassName,
                r["__CLASS"]);

            foreach (ManagementClass related in c.GetRelatedClasses(
                null, r.ClassPath.ClassName,
                "Association", null, null, null, null))
            {
                Console.WriteLine(
                    "{0} is related to " + c.ClassPath.ClassName,
                    related.ClassPath.ClassName);
            }
        } 

        return;
    }
}

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft