CODE : 여기VB.NET 배열 명시 적으로 선언 문제
Private ingredientProperties(,) As Integer = {{ingredient1.Location.X, ingredient1.Location.Y}, {ingredient1.Size.Width, ingredient1.Size.Height}} ' {{ingredient location X, Y}, {ingredient size X, Y}}
Private amountProperties(,) As Integer = {{amount1.Location.X, amount1.Location.Y}, {amount1.Size.Width, amount1.Size.Height}} ' {{amount location X, Y}, {amount size X, Y}}
내가 두 개의 2 차원 배열의 위치와 두 개의 텍스트 상자의 크기를 포함하는 클래스의 범위를 선언하고있다. 이 오류가 발생하는 것이 확실합니다.
An unhandled exception of type 'System.InvalidOperationException' occurred in Recipe Manager.exe Additional information: An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object.
위치 및 크기가 아직 존재하지 않으므로 선언 할 수있는 다른 방법이 있습니까?
왜하지 다른 옵션이 초기화 된 후에 배열을 초기화합니까? 이전에 해보고 시도하는 것은 의미가 없습니다. 무엇을 성취하려고합니까? – Jens
배열의 범위가 내 전체 클래스가되어야합니다. ** Form_Load ** 이벤트 처리기에서 수행하는 경우 나머지 클래스에서 액세스 할 수 없습니다. – ohSkittle
범위는 선언에 의해 결정되며 초기화. 예 : 클래스에 'Private ingredientProperties (,) As Integer'라는 줄이 있다면'ingredientsProperties = {{ingredients1.Location.X, ingredients1.Location.Y}, {ingredients1.Size.Width, ingredient1.Size. Height}}''Form_Load'에서 변수가 초기화되고 원하는대로 액세스 할 수 있습니다. – Jens