Description


I am a junior programmer.
I want you to debug the above problems, may not be as simple as you think.
This makes me very confused and I would like to have a.NET expert help explain.
Reproduction Steps
100%
Expected behavior
Cannot apply indexing with [] to an expression of type 'object'
Actual behavior
An exception will be thrown if the type is not public (Cannot apply indexing with [] to an expression of type 'object')
It's easy to understand that the runtime environment finds out that it's a protected type so it throws an exception but you can access it directly with foreach whether test is a protected type or not private
Regression?
An exception will be thrown if the type is not public (Cannot apply indexing with [] to an expression of type 'object')
It's easy to understand that the runtime environment finds out that it's a protected type so it throws an exception but you can access it directly with foreach whether test is a protected type or not private
Known Workarounds
An exception will be thrown if the type is not public (Cannot apply indexing with [] to an expression of type 'object')
It's easy to understand that the runtime environment finds out that it's a protected type so it throws an exception but you can access it directly with foreach whether test is a protected type or not private
Configuration
.net 6
Other information
No response
Description
I am a junior programmer.
I want you to debug the above problems, may not be as simple as you think.
This makes me very confused and I would like to have a.NET expert help explain.
Reproduction Steps
100%
Expected behavior
Cannot apply indexing with [] to an expression of type 'object'
Actual behavior
An exception will be thrown if the type is not public (Cannot apply indexing with [] to an expression of type 'object')
It's easy to understand that the runtime environment finds out that it's a protected type so it throws an exception but you can access it directly with foreach whether test is a protected type or not private
Regression?
An exception will be thrown if the type is not public (Cannot apply indexing with [] to an expression of type 'object')
It's easy to understand that the runtime environment finds out that it's a protected type so it throws an exception but you can access it directly with foreach whether test is a protected type or not private
Known Workarounds
An exception will be thrown if the type is not public (Cannot apply indexing with [] to an expression of type 'object')
It's easy to understand that the runtime environment finds out that it's a protected type so it throws an exception but you can access it directly with foreach whether test is a protected type or not private
Configuration
.net 6
Other information
No response