By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,883 Members | 1,952 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,883 IT Pros & Developers. It's quick & easy.

what does <object>["text"] mean?

P: 2
Being new to VB, I'm trying to understand what a construct like ["name"] means and how to use it. I thought anything with brackets is an escaped variable to allow using keywords like boolean, as in [boolean]. But I don't get this construct, especially in conjuction with an object, as in mo["name"] in the example below. Is mo["name"] an array element? What exactly is it and how do you use it?

Console.WriteLine("Computer details retrieved using Windows Management Instrumentation (WMI)");
ManagementObjectSearcher query1 = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");
ManagementObjectCollection queryCollection1 = query1.Get();
foreach (ManagementObject mo in queryCollection1)
{
Console.WriteLine("Name : " + mo["name"].ToString());
Console.WriteLine("Version : " + mo["version"].ToString());
}
Sep 10 '07 #1
Share this Question
Share on Google+
4 Replies


VBPhilly
P: 95
Being new to VB, I'm trying to understand what a construct like ["name"] means and how to use it. I thought anything with brackets is an escaped variable to allow using keywords like boolean, as in [boolean]. But I don't get this construct, especially in conjuction with an object, as in mo["name"] in the example below. Is mo["name"] an array element? What exactly is it and how do you use it?

Console.WriteLine("Computer details retrieved using Windows Management Instrumentation (WMI)");
ManagementObjectSearcher query1 = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");
ManagementObjectCollection queryCollection1 = query1.Get();
foreach (ManagementObject mo in queryCollection1)
{
Console.WriteLine("Name : " + mo["name"].ToString());
Console.WriteLine("Version : " + mo["version"].ToString());
}
It looks like an array or collection.
However, the curly braces tell me this is not VB.
I would check with the C# folks to be certain. But, I think "mo" is an array/collection and the "name" and "versions" are indexes of the mo object.
Sep 10 '07 #2

VBPhilly
P: 95
Being new to VB, I'm trying to understand what a construct like ["name"] means and how to use it. I thought anything with brackets is an escaped variable to allow using keywords like boolean, as in [boolean]. But I don't get this construct, especially in conjuction with an object, as in mo["name"] in the example below. Is mo["name"] an array element? What exactly is it and how do you use it?

Console.WriteLine("Computer details retrieved using Windows Management Instrumentation (WMI)");
ManagementObjectSearcher query1 = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");
ManagementObjectCollection queryCollection1 = query1.Get();
foreach (ManagementObject mo in queryCollection1)
{
Console.WriteLine("Name : " + mo["name"].ToString());
Console.WriteLine("Version : " + mo["version"].ToString());
}
Ok, I figured I could give some more detail

mo is an object of type ManagementObject which exists in the queryCollection1 which is of type ManagementObjectCollection.
mo is the object, "name" and "version" are properties of ManagementObject. I hope I donthave to explain ToString to you :)
Sep 10 '07 #3

Expert 5K+
P: 8,434
Looks like Java, to me.
Sep 10 '07 #4

P: 2
Thank you all. I saw that code chunk on a web site under VB samples and I thought there was something in VB that I couldn't figure out. You are right. It is some other language.
Sep 11 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.