How to use C # structure
This article introduces the relevant knowledge of "how to use the C# structure". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Example
Using System
Using System.Text
Struct Books
{
Public string title
Public string author
Public string subject
Public int book_id
}
Public class testStructure
{
Public static void Main (string [] args)
{
Books Book1; / * declares Book1 with type Books * /
Books Book2; / * declares Book2 with type Books * /
/ * book 1 details * /
Book1.title = "C Programming"
Book1.author = "Nuha Ali"
Book1.subject = "C Programming Tutorial"
Book1.book_id = 6495407
/ * book 2 details * /
Book2.title = "Telecom Billing"
Book2.author = "Zara Ali"
Book2.subject = "Telecom Billing Tutorial"
Book2.book_id = 6495700
/ * print Book1 information * /
Console.WriteLine ("Book1 title: {0}", Book1.title)
Console.WriteLine ("Book1 author: {0}", Book1.author)
Console.WriteLine ("Book1 subject: {0}", Book1.subject)
Console.WriteLine ("Book1 book_id: {0}", Book1.book_id)
/ * print Book2 information * /
Console.WriteLine ("Book2 title: {0}", Book2.title)
Console.WriteLine ("Book2 author: {0}", Book2.author)
Console.WriteLine ("Book2 subject: {0}", Book2.subject)
Console.WriteLine ("Book2 book_id: {0}", Book2.book_id)
Console.ReadKey ()
}
}
When the above code is compiled and executed, it produces the following results:
Book 1 title: C ProgrammingBook 1 author: Nuha AliBook 1 subject: C Programming TutorialBook 1 book_id: 6495407Book 2 title: Telecom BillingBook 2 author: Zara AliBook 2 subject: Telecom Billing TutorialBook 2 book_id: 6495700 "how to use the C # structure", thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!