How to know which .NET Api Compatibility Level is using in C# code?

Hi, pals, I want to coding some C# code in common use for our team members.

But I don’t know how to recognize which .NET version is using in C# script.

For example, I have some codes need .NET 2.1, but I don’t want the Unity report an error if someone use other codes only need .NET 1.1.

Is there any “#define” can let me use “#if” to recognize it?

Such as:

#if DOT_NET_2_1

..... //.NET 2.1 codes here

#else

.... //.NET 1.1 codes here

#endif

Does anyone know about it?

Thank you. :wink:

There doesn’t seem to be a direct way to do this in Unity (all the available compilation flags are listed here).

.NET 1.1 is not supported in U3 anymore at all.
The only platform that used to support it was Unity iPhone 1.x but Unity 3 iOS only offers 2.0 and a 2.0 subset, .NET 1.1 support was cut during beta.

So technically you won’t hit cases with Unity code that enforces .NET 1.1 and won’t work with 2.0 anymore.