🍀 Unity
[C#] 구조체 struct
수구마
2025. 6. 1. 17:43

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HelloWorld : MonoBehaviour
{
struct Human
{
public string name;
public float height;
public float weight;
public float feetsize;
}
void Start()
{
Human cha = new Human();
cha.name = "철수";
cha.height = 198f;
cha.weight = 73;
cha.feetsize = 280;
Debug.Log("이름:" + cha.name +" 키: "+ cha.height);
}
}

참조 할 만한 사이트
C# Struct와 Class의 차이. 그리고 왜 사용할까?
기존 C언어에서는 Class라는 구분이 없이 Struct를 사용했다고 한다. 그렇기에 기존 C와 호환을 위해 Stuct를 사용한다.하지만 단순히 이러한 이유가 아닌 메모리 관리에 용이하다는 부분에서 계속
velog.io