C# Data Structures :

What Is a Data Structure?

Data structures is a set of data organized on the basis of logical and mathematical laws. Very often the choice of the right data structure makes the program much more efficient and we could save memory and execution time

Defining a Structure :

To define a structure, you must use the struct statement. The struct statement defines a new data type, with more than one member for your program.For example, here is the way you can declare the Computer specification structure:

Syntax :

struct Computer
{
public string cpu;
public string mbd;
public string gpu;
public int ram;
public int hdd;
};


Example :

  1. /* Description: simple Computer specification using structure */
  2. using System;
  3. struct Computer
  4. {
  5. public string cpu;
  6. public string mbd;
  7. public string gpu;
  8. public int ram;
  9. public int hdd;
  10. };
  11. namespace DemoProgramming
  12. {
  13. class Program
  14. {
  15. static void Main()
  16. {
  17. Computer specification;
  18. specification.cpu = "Intel Core i9 Processor";
  19. specification.mbd = "MSI Extreme Gaming Intel X99 (X99A GODlike Gaming)";
  20. specification.gpu = "RTX 2080 Ti 11GB";
  21. specification.ram = 32;
  22. specification.hdd = 4;
  23. Console.WriteLine("Processor : {0}", specification.cpu);
  24. Console.WriteLine("Motherboard : {0}", specification.mbd);
  25. Console.WriteLine("Graphic Card : {0}", specification.gpu);
  26. Console.WriteLine("RAM : {0} GB", specification.ram);
  27. Console.WriteLine("HardDisk : {0} TB", specification.hdd);
  28. Console.ReadKey();
  29. }
  30. }
  31. }

Output :

C Sharp Language simple Computer specification using structure

Next Update

Loading...

Currently we improved our website User Interface and other contents. Our next update is adding video tutorials on this site so, We create a new YouTube channel, our YouTube channel name is CodeX.

We need some time for make video tutorials (CodeX) so, stay with us and keep supporting and you know already we make a Collaboration with HackIsOn YouTube channel long time ago So, please Subscribe Our Channels