using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CSharpStruct
{
struct Books
{
public string title;
public string author;
public string subject;
public int id;
}
class Program
{
static void Main(string[] args)
{
Books b1, b2;
b1.title = "Little Inspiration";
b1.author = "Mahi";
b1.subject = "Quotes";
b1.id = 5;
Console.WriteLine("Book 1 title : {0}", b1.title);
Console.WriteLine("Book 1 author : {0}", b1.author);
Console.WriteLine("Book 1 subject : {0}", b1.subject);
Console.WriteLine("Book 1 book_id :{0}", b1.id);
Console.WriteLine();
b2.title = "Suvichar";
b2.author = "Jignesh Trivedi";
b2.subject = "Quotes";
b2.id = 10;
Console.WriteLine("Book 2 title : {0}", b2.title);
Console.WriteLine("Book 2 author : {0}", b2.author);
Console.WriteLine("Book 2 subject : {0}", b2.subject);
Console.WriteLine("Book 2 book_id : {0}", b2.id);
Console.ReadLine();
}
}
}
Output:
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CSharpStruct
{
struct Books
{
public string title;
public string author;
public string subject;
public int id;
}
class Program
{
static void Main(string[] args)
{
Books b1, b2;
b1.title = "Little Inspiration";
b1.author = "Mahi";
b1.subject = "Quotes";
b1.id = 5;
Console.WriteLine("Book 1 title : {0}", b1.title);
Console.WriteLine("Book 1 author : {0}", b1.author);
Console.WriteLine("Book 1 subject : {0}", b1.subject);
Console.WriteLine("Book 1 book_id :{0}", b1.id);
Console.WriteLine();
b2.title = "Suvichar";
b2.author = "Jignesh Trivedi";
b2.subject = "Quotes";
b2.id = 10;
Console.WriteLine("Book 2 title : {0}", b2.title);
Console.WriteLine("Book 2 author : {0}", b2.author);
Console.WriteLine("Book 2 subject : {0}", b2.subject);
Console.WriteLine("Book 2 book_id : {0}", b2.id);
Console.ReadLine();
}
}
}
Output:
No comments:
Post a Comment