The Environment class in the System namespace has this information.
[C#]
string versionText = Environment.OSVersion.Version.ToString();
[VB.NET]
Dim versionText As String = Environment.OSVersion.Version.ToString()
The Version property has member properties such as Major and Minor that give additional information.
Note that XP is windows version 5.1