{"id":1202,"date":"2023-07-31T09:00:00","date_gmt":"2023-07-31T09:00:00","guid":{"rendered":"https:\/\/www.naveedulhaq.com\/?p=1202"},"modified":"2023-07-28T14:37:00","modified_gmt":"2023-07-28T14:37:00","slug":"c-struct-defining-lightweight-data-types","status":"publish","type":"post","link":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/","title":{"rendered":"C# Struct: Defining Lightweight Data Types for Performance"},"content":{"rendered":"\n<p>In <a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/csharp\/tour-of-csharp\/\" target=\"_blank\" rel=\"noreferrer noopener\">C#<\/a> programming, a struct is a valuable feature that allows you to create lightweight data types for efficient memory utilization and performance improvements. Structs are ideal for representing small data structures that do not require the overhead of a class. In this article, we\u2019ll explore the usage of C# structs, their benefits, and when to use them to optimize your code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"understanding-c-structs\"><strong>Understanding C# Struct<\/strong><\/h2>\n\n\n\n<p>A struct in C# is a value type that encapsulates a small set of related data fields. It is similar to a class but differs in key aspects, such as memory allocation and behavior, when passed as arguments. Structs are stack-allocated, meaning they are stored directly in memory where they are declared. This contrasts with classes, which are heap-allocated.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"creating-and-using-a-c-struct\"><strong>Creating and Using a C# Struct<\/strong><\/h2>\n\n\n\n<p>Let\u2019s explore an example of creating a C# struct and using it to represent a 2D point:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public struct Point\n{\n    public int X;\n    public int Y;\n\n    \/\/ Constructor\n    public Point(int x, int y)\n    {\n        X = x;\n        Y = y;\n    }\n}\n\n\/\/ Using the Point struct\nclass Program\n{\n    static void Main()\n    {\n        \/\/ Create a new Point instance\n        Point point = new Point(10, 5);\n\n        \/\/ Accessing struct members\n        Console.WriteLine($\"X: {point.X}, Y: {point.Y}\"); \/\/ Output: X: 10, Y: 5\n\n        \/\/ Modifying struct members (value semantics)\n        Point modifiedPoint = point;\n        modifiedPoint.X = 20;\n        Console.WriteLine($\"Modified X: {modifiedPoint.X}, Original X: {point.X}\"); \/\/ Output: Modified X: 20, Original X: 10\n    }\n}\n<\/code><\/pre>\n\n\n\n<p>In this example, we define a struct named&nbsp;<code>Point<\/code>&nbsp;with two integer fields:&nbsp;<code>X<\/code>&nbsp;and&nbsp;<code>Y<\/code>. We also provide a constructor to initialize the struct fields. In the&nbsp;<code>Main<\/code>&nbsp;method, we create a new&nbsp;<code>Point<\/code>&nbsp;instance and demonstrate how to access and modify the struct members.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"benefits-of-using-structs\"><strong>Benefits of Using C# Struct<\/strong><\/h2>\n\n\n\n<p>Using structs in C# can offer several benefits, especially for small data structures:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"memory-efficiency\"><strong>1. Memory Efficiency<\/strong><\/h3>\n\n\n\n<p>Structs are stack-allocated, making them more memory-efficient than heap-allocated classes. For small data structures, such as a point with X and Y coordinates, using a struct can save memory and reduce the overhead associated with heap allocation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"performance-improvements\"><strong>2. Performance Improvements<\/strong><\/h3>\n\n\n\n<p>Due to their stack-based nature, accessing struct members is faster compared to accessing class members stored on the heap. For performance-critical scenarios, using structs can lead to significant performance improvements.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"value-semantics\"><strong>3. Value Semantics<\/strong><\/h3>\n\n\n\n<p>Structs in C# have value semantics. When you assign a struct to another variable or pass it as a method argument, a copy of the struct is created. This ensures that modifications to the copy do not affect the original struct, making them suitable for scenarios where you need independent copies.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"interoperability\"><strong>4. Interoperability<\/strong><\/h3>\n\n\n\n<p>Structs are useful for interoperability scenarios, such as when working with unmanaged code or interacting with low-level APIs that expect specific memory layouts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"guidelines-for-using-structs\"><strong>Guidelines for Using Structs<\/strong><\/h2>\n\n\n\n<p>While structs offer benefits in certain scenarios, they are not always a suitable replacement for classes. Consider the following guidelines when deciding whether to use a struct or a class:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"size-and-complexity\"><strong>1. Size and Complexity<\/strong><\/h3>\n\n\n\n<p>Structs are best suited for small and simple data structures with just a few fields. Avoid defining large and complex structures (structs), as they can lead to performance and maintainability issues.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"immutability\"><strong>2. Immutability<\/strong><\/h3>\n\n\n\n<p>Consider making struct fields immutable (read-only) to preserve the value semantics. Immutable structs behave predictably, and modifications require creating a new instance with the desired changes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"semantics\"><strong>3. Semantics<\/strong><\/h3>\n\n\n\n<p>Ensure that the struct\u2019s behavior aligns with value semantics. For example, a struct representing a 2D point should not have methods with side effects or behavior that contradicts value semantics.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"boxed-copies\"><strong>4. Boxed Copies<\/strong><\/h3>\n\n\n\n<p>Be cautious when boxing and unboxing structs. When a struct is boxed (converted to an object), it loses its performance benefits as it\u2019s now heap-allocated. Avoid unnecessary boxing operations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>C# structs provide an efficient and performant way to represent small data structures in your code. By utilizing structs for lightweight data types, you can achieve memory efficiency, improve performance, and ensure value semantics. However, remember that structs are not a one-size-fits-all solution, and using them appropriately requires careful consideration of the size, complexity, and semantics of your data structures. <\/p>\n\n\n\n<p>By following the guidelines and best practices outlined in this article, you can leverage C# structs effectively to optimize your code.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.naveedulhaq.com\/index.php\/category\/dot-net-core\/\" target=\"_blank\" rel=\"noreferrer noopener\">Learn More About C#\/.NET Here!<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In C# programming, a struct is a valuable feature that allows you to create lightweight data types for efficient memory utilization and performance improvements. Structs&#8230;<\/p>\n","protected":false},"author":3,"featured_media":641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[11,8,62,37,32,23,56],"class_list":["post-1202","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dot-net-core","tag-dot-net-core","tag-dot-net-framework","tag-asp-net","tag-c","tag-developer","tag-development","tag-visual-studio"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>C# Struct: Defining Lightweight Data Types for Performance - Naveed Ul-Haq&#039;s blog<\/title>\n<meta name=\"description\" content=\"C# struct provides an efficient and performant way to represent small data structures in your code. Read this detailed guide here!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C# Struct: Defining Lightweight Data Types for Performance - Naveed Ul-Haq&#039;s blog\" \/>\n<meta property=\"og:description\" content=\"C# struct provides an efficient and performant way to represent small data structures in your code. Read this detailed guide here!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/\" \/>\n<meta property=\"og:site_name\" content=\"Naveed Ul-Haq&#039;s blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-31T09:00:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png\" \/>\n\t<meta property=\"og:image:width\" content=\"240\" \/>\n\t<meta property=\"og:image:height\" content=\"240\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Abdul Mannan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Abdul Mannan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/c-struct-defining-lightweight-data-types\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/c-struct-defining-lightweight-data-types\\\/\"},\"author\":{\"name\":\"Abdul Mannan\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/8babf3cd198e47e5c727f67880ea7977\"},\"headline\":\"C# Struct: Defining Lightweight Data Types for Performance\",\"datePublished\":\"2023-07-31T09:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/c-struct-defining-lightweight-data-types\\\/\"},\"wordCount\":620,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/dd6db5980b965fcae41e096d357c65c9\"},\"image\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/c-struct-defining-lightweight-data-types\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.naveedulhaq.com\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/240px-.NET_Logo.svg_.png\",\"keywords\":[\".net core\",\".net framework\",\"asp.net\",\"c#\",\"developer\",\"development\",\"visual-studio\"],\"articleSection\":[\".NET\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/c-struct-defining-lightweight-data-types\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/c-struct-defining-lightweight-data-types\\\/\",\"url\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/c-struct-defining-lightweight-data-types\\\/\",\"name\":\"C# Struct: Defining Lightweight Data Types for Performance - Naveed Ul-Haq&#039;s blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/c-struct-defining-lightweight-data-types\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/c-struct-defining-lightweight-data-types\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.naveedulhaq.com\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/240px-.NET_Logo.svg_.png\",\"datePublished\":\"2023-07-31T09:00:00+00:00\",\"description\":\"C# struct provides an efficient and performant way to represent small data structures in your code. Read this detailed guide here!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/c-struct-defining-lightweight-data-types\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/c-struct-defining-lightweight-data-types\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/c-struct-defining-lightweight-data-types\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.naveedulhaq.com\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/240px-.NET_Logo.svg_.png\",\"contentUrl\":\"https:\\\/\\\/www.naveedulhaq.com\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/240px-.NET_Logo.svg_.png\",\"width\":240,\"height\":240,\"caption\":\".net\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/c-struct-defining-lightweight-data-types\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.naveedulhaq.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C# Struct: Defining Lightweight Data Types for Performance\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#website\",\"url\":\"https:\\\/\\\/www.naveedulhaq.com\\\/\",\"name\":\"Naveed Ul-Haq's blog\",\"description\":\"AI, Optimizely, Azure &amp; more\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/dd6db5980b965fcae41e096d357c65c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.naveedulhaq.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/dd6db5980b965fcae41e096d357c65c9\",\"name\":\"Naveed Ul-Haq\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g\",\"caption\":\"Naveed Ul-Haq\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g\"},\"description\":\"I lead engineering delivery teams for digital commerce and digital experience platforms, combining hands-on architecture experience with strong delivery governance. Over 20+ years, I\u2019ve built and led cross\u2011functional teams (engineering, BA, QA) delivering modern cloud solutions on Azure, microservices, APIs and eCommerce\\\/CMS platforms. My recent focus includes AI-enabled commerce automation: product ingestion and enrichment workflows, content optimisation for SEO and shopping feeds, and agentic tooling to improve marketing and accessibility workflows. I\u2019m passionate about building high-performing teams, establishing quality\\\/release standards, and delivering measurable outcomes across performance, reliability, and speed of change.\",\"sameAs\":[\"https:\\\/\\\/www.naveedulhaq.com\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/naveedulhaq\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/8babf3cd198e47e5c727f67880ea7977\",\"name\":\"Abdul Mannan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g\",\"caption\":\"Abdul Mannan\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C# Struct: Defining Lightweight Data Types for Performance - Naveed Ul-Haq&#039;s blog","description":"C# struct provides an efficient and performant way to represent small data structures in your code. Read this detailed guide here!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/","og_locale":"en_GB","og_type":"article","og_title":"C# Struct: Defining Lightweight Data Types for Performance - Naveed Ul-Haq&#039;s blog","og_description":"C# struct provides an efficient and performant way to represent small data structures in your code. Read this detailed guide here!","og_url":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/","og_site_name":"Naveed Ul-Haq&#039;s blog","article_published_time":"2023-07-31T09:00:00+00:00","og_image":[{"width":240,"height":240,"url":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png","type":"image\/png"}],"author":"Abdul Mannan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Abdul Mannan","Estimated reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/#article","isPartOf":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/"},"author":{"name":"Abdul Mannan","@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/8babf3cd198e47e5c727f67880ea7977"},"headline":"C# Struct: Defining Lightweight Data Types for Performance","datePublished":"2023-07-31T09:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/"},"wordCount":620,"commentCount":0,"publisher":{"@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/dd6db5980b965fcae41e096d357c65c9"},"image":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/#primaryimage"},"thumbnailUrl":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png","keywords":[".net core",".net framework","asp.net","c#","developer","development","visual-studio"],"articleSection":[".NET"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/","url":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/","name":"C# Struct: Defining Lightweight Data Types for Performance - Naveed Ul-Haq&#039;s blog","isPartOf":{"@id":"https:\/\/www.naveedulhaq.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/#primaryimage"},"image":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/#primaryimage"},"thumbnailUrl":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png","datePublished":"2023-07-31T09:00:00+00:00","description":"C# struct provides an efficient and performant way to represent small data structures in your code. Read this detailed guide here!","breadcrumb":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/#primaryimage","url":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png","contentUrl":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png","width":240,"height":240,"caption":".net"},{"@type":"BreadcrumbList","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/c-struct-defining-lightweight-data-types\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.naveedulhaq.com\/"},{"@type":"ListItem","position":2,"name":"C# Struct: Defining Lightweight Data Types for Performance"}]},{"@type":"WebSite","@id":"https:\/\/www.naveedulhaq.com\/#website","url":"https:\/\/www.naveedulhaq.com\/","name":"Naveed Ul-Haq's blog","description":"AI, Optimizely, Azure &amp; more","publisher":{"@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/dd6db5980b965fcae41e096d357c65c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.naveedulhaq.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":["Person","Organization"],"@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/dd6db5980b965fcae41e096d357c65c9","name":"Naveed Ul-Haq","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g","caption":"Naveed Ul-Haq"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g"},"description":"I lead engineering delivery teams for digital commerce and digital experience platforms, combining hands-on architecture experience with strong delivery governance. Over 20+ years, I\u2019ve built and led cross\u2011functional teams (engineering, BA, QA) delivering modern cloud solutions on Azure, microservices, APIs and eCommerce\/CMS platforms. My recent focus includes AI-enabled commerce automation: product ingestion and enrichment workflows, content optimisation for SEO and shopping feeds, and agentic tooling to improve marketing and accessibility workflows. I\u2019m passionate about building high-performing teams, establishing quality\/release standards, and delivering measurable outcomes across performance, reliability, and speed of change.","sameAs":["https:\/\/www.naveedulhaq.com","https:\/\/www.linkedin.com\/in\/naveedulhaq\/"]},{"@type":"Person","@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/8babf3cd198e47e5c727f67880ea7977","name":"Abdul Mannan","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g","caption":"Abdul Mannan"}}]}},"_links":{"self":[{"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/posts\/1202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/comments?post=1202"}],"version-history":[{"count":0,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/posts\/1202\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/media\/641"}],"wp:attachment":[{"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/media?parent=1202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/categories?post=1202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/tags?post=1202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}