I think there is not such direct way to get C# version (at least I didn't find), however you can determine the .NET Framework version and conclude the C# version.
To know the .NET Framework version, write following code
string s = Environment.Version.ToString();
There are other property of Version as well to know the major and minor version of the .NET Framework.
Once you have the .NET Framework version you can determine the C# version based on following
.NET Framework 2 - C# 2
.NET Framework 3 - C# 2
.NET Framework 3.5 - C# 3
.NET Framework 4 - C# 4
To know more about version class, read this
http://msdn.microsoft.com/en-us/library/system.version.aspx
Thanks!
Regards,
Sheo Narayan
http://www.dotnetfunda.com
Gayathri, if this helps please login to Mark As Answer. | Alert Moderator