Home > Net >  ManagementObject ManagementBaseObject and what is the difference between these two classes?
ManagementObject ManagementBaseObject and what is the difference between these two classes?

Time:10-01

Didn't feel what is the difference between when using, as shown in the following code:
 static int Main (string [] args) {
ManagementClass diskClass=
New ManagementClass (" Win32_LogicalDisk ");
ManagementObjectCollection disks=
DiskClass. GetInstances ();
ManagementObjectCollection. ManagementObjectEnumerator
DisksEnumerator=
Disks. GetEnumerator ();
While (disksEnumerator. MoveNext ()) {
ManagementObject disk=(ManagementObject) disksEnumerator. Current;
//ManagementBaseObject disk=disksEnumerator. Current;//this can also be ah, why do they go?
Console. WriteLine (
"Disk found:" + Disk (" deviceid "));
}
return 0;
}

CodePudding user response:

The name will know that the latter is the base class of the former, what's the difference between the base class and derived class? What's the difference between you and your dad?

CodePudding user response:

The
reference 1/f, nan peony reply:
the name will know that the latter is the base class of the former, what's the difference between the base class and derived class? What's the difference between you and your dad?

Sometimes no different to use, you can get the same result,

CodePudding user response:

Their F2 in to look at

CodePudding user response:

reference exception92 reply: 3/f
their F2 in to see

In I put this code, these two classes use effect is the same, don't understand.

CodePudding user response:

reference 4 floor jlennonxzy response:
Quote: reference exception92 reply: 3/f

Their F2 in to see

In I put this code, these two classes use effect is the same, not quite understand.

Maybe just name is different

CodePudding user response:

In your ManagementObject F12 and see if he's inherited from ManagementBaseObject

CodePudding user response:

reference 6 floor is anger god reply:
you on ManagementObject F12, and see that he inherited from ManagementBaseObject

Subclass is no doubt, I just don't understand why forced into subclasses, this is in the MSDN example,

CodePudding user response:

refer to 7th floor jlennonxzy response:
Quote: refer to the sixth floor is nu month god reply:
you on ManagementObject F12, and see that he inherited from ManagementBaseObject

Subclass is no doubt, I just don't understand why forced into subclasses, this is in the MSDN example,

Because parents have children without methods and properties,
And since he could into subclasses that into method, is likely to be a subclass,
  •  Tags:  
  • C#
  • Related