{"id":426,"date":"2020-04-26T09:09:54","date_gmt":"2020-04-26T08:09:54","guid":{"rendered":"https:\/\/ibex.tech\/csharp\/?p=426"},"modified":"2022-02-17T06:24:14","modified_gmt":"2022-02-17T06:24:14","slug":"classes-simple-data-class","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/c-sharp\/classes\/classes-simple-data-class","title":{"rendered":"Classes-Simple Data Class"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Very basic class<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\tpublic class DataGridData\n\t{\n\t\tpublic string Category { get; set; }\n\t\tpublic double Value1 { get; set; }\n\t\tpublic bool Value2 { get; set; }\n\t}<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Using it<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\tDataGridData DataGridData1 = new DataGridData() { Category = \"Cat0\", Value1 = 1000, Value2 = true };\n\t\/\/or like this\n\tDataGridData DataGridData2 = new DataGridData();\n\tDataGridData2.Category = \"Cat2\";\n\tDataGridData2.Value1 = 1002;\n\tDataGridData2.Value2 = true;<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Using it for a list<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>public List&lt;DataGridData> DataGridData1;\n\n\tDataGridData1 = new List&lt;DataGridData>();\n\tDataGridData1.Add(new DataGridData() { Category = \"Cat0\", Value1 = 1000, Value2 = true });\t\/\/&lt;&lt;You can do this instead of creating a constructor\n\tDataGridData1.Add(new DataGridData() { Category = \"Cat1\", Value1 = 1001, Value2 = false });\n\t\/\/or like this\n\tDataGridData1.Add(new DataGridData());\n\tDataGridData1&#91;(DataGridData1.Count - 1)].Category = \"Cat2\";\n\tDataGridData1&#91;(DataGridData1.Count - 1)].Value1 = 1002;\n\tDataGridData1&#91;(DataGridData1.Count - 1)].Value2 = true;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Very basic class with a constructor<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\tpublic class DataGridData\n\t{\n\t\tpublic string Category { get; set; }\n\t\tpublic double Value1 { get; set; }\n\t\tpublic bool Value2 { get; set; }\n\n\t\t\/\/----- CONSTRUCTOR -----\n\t\tpublic DataGridData (string Category, double Value1, bool Value2)\n\t\t{\n\t\t\tthis.Category = Category;\n\t\t\tthis.Value1 = Value1;\n\t\t\tthis.Value2 = Value2;\n\t\t}\n\t}<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Using it<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\tDataGridData1 = new List&lt;DataGridData>();\n\tDataGridData1.Add(new DataGridData(\"Cat0\", 1000, true));\n\tDataGridData1.Add(new DataGridData(\"Cat1\", 1001, false));<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Very basic class Using it Using it for a list Very basic class with a constructor Using it<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-426","post","type-post","status-publish","format-standard","hentry","category-classes"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=426"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/426\/revisions"}],"predecessor-version":[{"id":429,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/426\/revisions\/429"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}