Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

struct

#include <stdio.h>

main () {
	struct person {
		char[] name;
		int age;
	}
}
Comment

struct in struct

// C program to implement
// the above approach
#include <stdio.h>
#include <string.h>

// Declaration of the
// dependent structure
struct Employee
{
  int employee_id;
  char name[20];
  int salary;
};

// Declaration of the
// Outer structure
struct Organisation
{
  char organisation_name[20];
  char org_number[20];

  // Dependent structure is used
  // as a member inside the main
  // structure for implementing
  // nested structure
  struct Employee emp;
};

// Driver code
int main()
{
  // Structure variable
  struct Organisation org;

  // Print the size of organisation
  // structure
  printf("The size of structure organisation : %ld
",
          sizeof(org));

  org.emp.employee_id = 101;
  strcpy(org.emp.name, "Robert");
  org.emp.salary = 400000;
  strcpy(org.organisation_name,
          "GeeksforGeeks");
  strcpy(org.org_number, "GFG123768");


  // Printing the details
  printf("Organisation Name : %s
",
          org.organisation_name);
  printf("Organisation Number : %s
",
          org.org_number);
  printf("Employee id : %d
",
          org.emp.employee_id);
  printf("Employee name : %s
",
          org.emp.name);
  printf("Employee Salary : %d
",
          org.emp.salary);
}
Comment

struct

public struct S : IDisposable
    {
        private bool dispose;
        public void Dispose()
        {
            dispose = true;
        }
        public bool GetDispose()
        {
            return dispose;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var s = new S(); 
            using (s)
            {
                Console.WriteLine(s.GetDispose());
            }
            Console.WriteLine(s.GetDispose());
        }
        /*result
         False
        False
         */
    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to close a popup wpf c# on click event 
Csharp :: Runtime.getRuntime().addShutdownHook(printingHook); c# 
Csharp :: c# how to start an application and detect if started 
Csharp :: pyqt single instance 
Csharp :: What does "DateTime?" mean in C#? 
Csharp :: c# compare char arrays 
Csharp :: null objects 
Csharp :: c# replace foreach with lambda 
Csharp :: init stirng list c# 
Csharp :: Dynamically checking IList<T C# 
Csharp :: appodeal unity integration 
Csharp :: unity gamemanager instance not set to an instance of an object 
Csharp :: c# wait without GUI blocks 
Csharp :: vb.net array search 
Csharp :: extension method c# 
Csharp :: custom vscode snippet 
Csharp :: string methods in c# 
Csharp :: c# is string nullable 
Csharp :: c# loop example 
Csharp :: transform face player unity 
Csharp :: c# movement script 
Csharp :: stackpanel opacity mask from resources wpf 
Csharp :: como guardar archivo en un botón asp.net 
Html :: qs cdn 
Html :: how to open link in new tab 
Html :: materialize cdn 
Html :: how to change h1 color in html 
Html :: how to add favicon in html 
Html :: vscode user code snippet not working markdown 
Html :: gender selection in html 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =