How can I get object's rotation in c#?

When a level is loaded, I need to somehow get the current rotation of the object like it shows in the Transform menu. Please?

http://unity3d.com/support/documentation/ScriptReference/Transform-eulerAngles.html

http://unity3d.com/support/documentation/ScriptReference/Transform-localEulerAngles.html

gameObject.transform.rotation.x; gameObject.transform.rotation.y; gameObject.transform.rotation.z;

These will return world coordinates.

gameObject.transform.localrotation.x; gameObject.transform.localrotation.y; gameObject.transform.localrotation.z;

These return local coordinates.

Is not possible to get access to the Rotation value that is inside inspector field of the component transform via code. But there is a workaround by using

float angleX = myTransformGO.rotation.eulerAngles.x; 
float angleY = myTransformGO.rotation.eulerAngles.y;
float angleZ = myTransformGO.rotation.eulerAngles.z;

Then using if statement and math to convert the result.

[PROBLEM SOLVED]

.

Skip all the above coments.

.

I found a way to get the exact rotation values as in INSPECTOR

.

.

I am showing for angle (x)

,The code is as follow

 public Transform GameObject;
 
 void Update()
 {
     float Rotation;
     if(GameObject.eulerAngles.x <= 180f)
     {
         Rotation = GameObject.eulerAngles.x;
     }
     else
     {
         Rotation = GameObject.eulerAngles.x - 360f;
     }
 }