

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Structure and Members of the C# Program
A structure is a value type data type. It helps you to make a single variable hold related data of various data types. The struct keyword is used for creating 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 Book structure. The following are the members −
struct Books { public string title; public string author; public string subject; public int id; };
To access and display these members in a structure −
Example
using System; struct Books { public string title; public string author; public int id; }; public class testStructure { public static void Main(string[] args) { Books Book1; Book1.title = "PHP IN 7 Days"; Book1.author = "Jacob Dawson"; Book1.id = 34; Console.WriteLine( "Book 1 title : {0}", Book1.title); Console.WriteLine("Book 1 author : {0}", Book1.author); Console.WriteLine("Book 1 book_id :{0}", Book1.id); Console.ReadKey(); } }
- Related Questions & Answers
- Structure and Members of the Java Program
- Write a C program to display the size and offset of structure members
- Flexible Array Members in a structure in C
- Declaring a structure with no members in C language
- C++ program to find sequence of indices of the team members
- How to pass individual members of structure as arguments to function in C language?
- C++ Program Structure
- Private and Protected Members in C++
- Get the members of the current Type in C#
- What is the basic structure of a C# program?
- Get the specified members of the current Type in C#?
- Difference between Structure and Union in C Program
- C program to compare the structure variables
- How to pass the individual members as arguments to function using structure elements?
- Get the names of the members of the current enumeration type in C#
Advertisements