내가이 개 수업을 왜 모르겠 음 아마 무언가 궁극적으로 간단합니다. 당신의 Player
생성자에서NullReferenceException이 나는
3
A
답변
6
, 당신이 새로운 필요 shots = new List<Shot>();
1
를 초기화 플레이어 생성자에서 샷 (또는 당신이 그것을 추가하기 전에).
shots = new List<Shot>();
0
나는 당신이 이제까지 접근 샷에 로직을 추가해야하는 경우에만 온통 샷의 사용을 변경하지 않고, 당신이 할 수있는 당신이 그것을 필요로하는 경우에 촬영을 초기화하고, 조금 더 아래를 좋아한다.
private List<Shot> _shots;
public List<Shot> Shots
{
get
{
if (_shots == null)
{
_shots = new List<Shot>();
}
return _shots;
}
set
{
_shots = value;
}
}
관련 문제
- 1. 나는 NullReferenceException이
- 2. NullReferenceException이
- 3. NullReferenceException이 오류
- 4. 이 NullReferenceException이
- 5. MVC NullReferenceException이
- 6. NullReferenceException이 발생합니다
- 7. 는 호출 "새 [클래스 명]"나는 새로운 클래스를 만들어 NullReferenceException이
- 8. Label.Text를 설정하려고하면 NullReferenceException이 발생합니다.
- 9. NullReferenceException이 발생하는 이유는 무엇입니까?
- 10. NullReferenceException이 처리되지 않은 # 2
- 11. NullReferenceException이 처리되지 않은했다 - 여기를
- 12. NullReferenceException이 처리하는 동안은 FileSystemWatcher는 []
- 13. ReSharper에서 도움말 : 가능한 NullReferenceException이
- 14. NullReferenceException이 검색 값
- 15. LINQ InsertOnSubmit : NullReferenceException이
- 16. "GetAvailablePageLayouts"에서 NullReferenceException이 발생했습니다
- 17. 로그인하는 동안 NullReferenceException이 발생합니다.
- 18. 는 NullReferenceException이 없애
- 19. MessagingSystem에서 NullReferenceException이 발생합니다.
- 20. NullReferenceException이 처리되지 않았습니다.
- 21. NullReferenceException이 심지어 IsDBNull
- 22. NHibernate에 NullReferenceException이 돌아 목록
- 23. NullReferenceException이 나는 이미지 에 대한 몇 가지 계산을 수행하는 응용 프로그램을 개발하고 있어요 동안은 루프의 시작 부분에 NullReferenceException이 제기 루프
- 24. NUnit을 사용할 때 NullReferenceException이 발생합니다.
- 25. 사전에 항목을 추가하면 NullReferenceException이 발생합니다.
- 26. 조건부 null 검사에서 NullReferenceException이 발생합니까?
- 27. UserControl로 인해 Designer에서 NullReferenceException이 발생했습니다.
- 28. System.Windows.Forms.Timer tick 이벤트에서 NullReferenceException이 발생합니다.
- 29. MyListProperty.Add를 사용할 때 NullReferenceException이 발생합니까?
- 30. Application.Run에서 NullReferenceException이 발생했습니다 (새 Main())
pl.shots = new 목록(); pl.shots.Add (새로운 샷 (pl.yPos)); –
AJP