Tuesday, 29 January 2013

Structure in C Sharp


By on 22:25

Structure in C#:-Structure is the collection of different type of element or heterogeneous element.

Condition's of data structure in C#:-

1)It is value type in c#.

2)Its memory allocation is static.

3)Initial Value is always 0.

4)All member are private(by defaults).

5)We can declare constructor in it.

Structure Example:-

struct book
{
public int r,p;
public string a,n;
public void read()
{
Console.WL("Enter book rate");
r=Convert.ToInt32(Console.ReadLine());
Console.WL('Enter pages");
p=Convert.ToInt32(Console.ReadLine());
Console.WL("Author name");
a=Console.ReadLine();

Console.WL("Name of book");
b=Console.ReadLine();
}
Public void write()
{
Console.WL("book rate="+r);
Console.WL('pages="+p);
Console.WL("Author name="+a);

Console.WL("Name of book="+n);
}
}
class program
{
static void main()
{
book bo;
bo.read();
bo.write();
}
}
}


If you have any query then leave your comments and don't forgot to follow me on Google+,Facebook,Twitter.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...