test_struct1.htm
Struct:: class Choices:
  • Struct Composite data type
  • Structs are only value type
  • Classes are referenced type
  • Struct uses stack , Class uses heap
    • Struct : No garbage collection, starts and ends with the clients calling the struct objects.
    • Class : Garbage collection in place
  • Structs can't inherit other structs or classes
  • Sturct can't be a base class
  • Struc does not support inheritance, members can't be specified as abstract, virtual or protected
  • Use of new to create an object is your choice to create specific constructors , and initialize this object manually.
Code used :

// Namespace Declaration
//File location : C:\BareBone_CSharp\Source_Code\Template
using System;
//csc test_struct1.cs
using System.Collections.Generic;
// Program start class
namespace testStruct1
{
struct Student{
public string name;
}
class CsharpTemplate
{
// Main begins program execution.
public static void Main(string[] str1)
{
testStruct1.Student student ;
Console.Write("Please eneter your name : " );
student.name =Console.ReadLine();
Console.Write("Welcome ");
Console.WriteLine(student.name);
}
}
//
}

Runtime display: