This website includes Education Information like a programming language, job interview question, general knowledge.mathematics

Education log

PageNavi Results No.

Ads

Tuesday, March 7, 2023

what is data structure in c#.net

 what is data structure in c#.net


In C#, 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. Structures are used to represent a record.



what is data structure in c#.net

In C#, 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.


Structures are used to represent a record. Suppose you want to keep track of your books in a library. 


example data structure in c#.net


// C# program to illustrate the

// Declaration of structure

using System;

namespace ConsoleApplication {


// Defining structure

public struct Person

{

// Declaring different data types

public string Name;

public int Age;

public int Weight;


}


class Geeks {

// Main Method

static void Main(string[] args)

{


// Declare P1 of type Person

Person P1;


// P1's data

P1.Name = "Keshav Gupta";

P1.Age = 21;

P1.Weight = 80;


// Displaying the values

Console.WriteLine("Data Stored in P1 is " +

P1.Name + ", age is " +

P1.Age + " and weight is " +

P1.Weight);


}

}

}


No comments:

Post a Comment