What 'type' of member is this?

  • Thread starter Thread starter garyusenet
  • Start date Start date
G

garyusenet

Console.WriteLine("Current OS: {0} ", Environment.OSVersion)

I'm trying to find out what .OSVersion is.

It returns an object which details the OS.

I know it's not a method, because it doesnt have any empty brackets ()
after it.

Is it a property?

How do i find out for future reference what 'type' of member a given
entity is after the period of a namespace? I tried using 'go to
defintion' and found this: -

public static OperatingSystem OSVersion { get; }

But this didn't really help me.

Could someone assist please.

Thanks,

Gary-
 
Hi,

Environment is a class that has a read-only property, OSVersion, of the
type, OperatingSystem.

IntelliSense will show you the type of the property in a tooltip when it's
selected in the list.

If you place your mouse over the property in code you'll see the type in a
tooltip.

In Visual Studio try using the Object Browser. You can search for the
property by entering, "OSVersion". Select System.Environment.OSVersion from
the search results and look at the definition in the right-hand, bottom
window. Since it's a property you'll see that the definition is in the form
of a property. You can click the type and it will show you more information
(the empty window above it will show all of the members of the
OperatingSystem type).

If you're not using Visual Studio you can use Reflector:

"Lutz Roeder's Progamming .NET"
http://www.aisto.com/roeder/dotnet/

You can also search MSDN:

"Results 1 - 25 of about 250 for osversion"
http://search.msdn.microsoft.com/search/default.aspx?siteId=0&tab=0&query=osversion

Choose the first result.
 
Hello Gary,

Environment.OSVersion.GetType()

Will get you the type of the property.
 
Hi,

My previous response was really aimed at discovering the framework Type, not
the type of the member, so I'll add this as well:
public static OperatingSystem OSVersion { get; }

It's a property because of the "{ get; }", but you don't need to go to the
definition to find that out. Actually, any of my previous suggestions could
also help you to discover the type of the member, but you can also do that
easily using the icons in the IntelliSense list (which I can't find a
reference to for some reason)
 
Hi thankyou both very much.

I find that the suggestion that I use the object browser is the one
that works for me because i can see the icon like you said Dave and I
can regonise the basic icon types!

thanks very much,

Gary-
 
Hi,

Hi thankyou both very much.

I find that the suggestion that I use the object browser is the one
that works for me because i can see the icon like you said Dave and I
can regonise the basic icon types!

thanks very much,

Gary-

Additionally to the other answers, note that the knowledge of
Microsoft's coding guidelines help to detect more easily what a given
identifier does. In that case, the Pascal casing and the lack of
parenthesis showed that it was a property.

http://blogs.msdn.com/brada/articles/361363.aspx

HTH,
Laurent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top