It's not a problem to use MakeArrayType()
if we want to make a array type of a specific type, for example, the char
array:
typeof(char).MakeArrayType()
Of course it's more intuitive to use typeof(char[])
instead.
And the property Assembly
of a type tells us what the assembly where the type is.
So the following code should be a reasonable example to find a type in an assembly:
var chars=new[] { '\x20' };
var typeofCharArray=chars.GetType();
var assembly=typeofCharArray.Assembly;
var doesContain=assembly.GetTypes().Contains(typeofCharArray);
But doesContain
says it DOESN'T, it's false
. This happens regardless the array type is from MakeArrayType()
or typeof()
, or an instance's GetType
.
There's a doubt that it was forwarded to other assemblies that I've read from Assembly.GetTypes. And I tried:
var assemblyContainsTypeOfCharArray=(
from it in AppDomain.CurrentDomain.GetAssemblies()
let types=it.GetTypes()
where types.Contains(typeof(char[]))
select it).FirstOrDefault();
The interesting thing is assemblyContainsTypeOfCharArray
is null
.
Where are the array types?