Constraints on rotation axis in c#

How do I create a constraint on a certain rotation axis in c#?..making an object rotate towards the mouse is easy but I cant seem to create the x and z constrains to keep it from spinning in every direction. … if I use transform.rotation.z = 0 I get an error in C#.

See this amazing tutorial from UnityGems, covers everything you need about rotations and Quaternions including your restrictions/constraints that you’re asking about (the “Rotating Around the Y Axis Only” section)