© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
4 replies
Nukadelic

❔ Is it possible to define a struct inline ?

instead of doing this
    [System.Serializable]
    public struct Properties
    {
        public float clipDistance;
        public float clipHeight;
        public float scale;
        public float3 rotation;
        public float rotationSpeed;
        public float floatDistance;
        public float floatSpeed;
    }

    public Properties properties = new Properties
    {
        clipDistance = 100,
        clipHeight = 10,
        scale = 0.4f,
        rotation = new float3(90, 0, 0),
        rotationSpeed = 1,
        floatDistance = 0.2f,
        floatSpeed = 0.2f,
    };
    [System.Serializable]
    public struct Properties
    {
        public float clipDistance;
        public float clipHeight;
        public float scale;
        public float3 rotation;
        public float rotationSpeed;
        public float floatDistance;
        public float floatSpeed;
    }

    public Properties properties = new Properties
    {
        clipDistance = 100,
        clipHeight = 10,
        scale = 0.4f,
        rotation = new float3(90, 0, 0),
        rotationSpeed = 1,
        floatDistance = 0.2f,
        floatSpeed = 0.2f,
    };

i want something like this :
public properties = new [System.Serializable] public struct Properties
{
        public float clipDistance = 100,
        public float clipHeight = 10,
        public float scale = 0.4f,
        public float3 rotation = new float3(90, 0, 0),
        public float rotationSpeed = 1,
        public float floatDistance = 0.2f,
        public float floatSpeed = 0.2f,
};
public properties = new [System.Serializable] public struct Properties
{
        public float clipDistance = 100,
        public float clipHeight = 10,
        public float scale = 0.4f,
        public float3 rotation = new float3(90, 0, 0),
        public float rotationSpeed = 1,
        public float floatDistance = 0.2f,
        public float floatSpeed = 0.2f,
};
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Is it possible to serialize this struct?
C#CC# / help
3y ago
Inline array of struct assignment
C#CC# / help
3y ago