인프런 커뮤니티 질문&답변
FieldInfo 형식 또는 네임스페이스를 찾을 수 없다는데
작성
·
1K
0
심각도 코드 설명 프로젝트 파일 줄 비표시 오류(Suppression) 상태
오류 CS0246 'FieldInfo' 형식 또는 네임스페이스 이름을 찾을 수 없습니다. using 지시문 또는 어셈블리 참조가 있는지 확인하세요.
뭐가 잘못된지 모르겠네요
답변 2
0
0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Csharp
{
class Monster
{
public int hp;
protected int attack;
private int speed;
void Attack( ) { }
}
class Program
{
static void Main(string[] args)
{
Monster reflectionMonster = new Monster();
Type type = reflectionMonster.GetType();
var fields = type.GetFields(System.Reflection.BindingFlags.Public
| System.Reflection.BindingFlags.NonPublic
| System.Reflection.BindingFlags.Static
| System.Reflection.BindingFlags.Instance);
foreach (FieldInfo field in fields)
{
string access = "protected";
if (field.IsPublic)
{
access = "public";
}
}
}
}
}






감사합니다!