What is metadata in .NET?

后端 未结 6 1636

I googled several sites to understand what metadata is in .NET and it means.

I\'m still new to C# WPF desktop application programming. Back when I was

6条回答
  •  感动是毒
    2020-12-23 00:34

    If you're familiar with .NET Reflection you can think of metadata as "the data that Reflection accesses". Each .NET assembly stores information about what types and methods it contains, the attributes on those methods, etc. It wouldn't need to store that just to run the code (native EXEs don't have that kind of information), but it needs it for other purposes, like enforcing declarative security and enabling Reflection.

    So metadata is "something physical", but most of it is automatically generated from the code you write. Adding attributes to your classes or methods is probably the only way you can directly change metadata. In particular, your source code comments will not be stored in the assembly as metadata (or in any other way).

    The Wikipedia page on this is pretty good: http://en.wikipedia.org/wiki/.NET_metadata

    Edit: No, metadata is not like comments. It is simply "data about the code", which is not part of the code itself (not needed to run the program). It's not like the HTML metadata at all. An example of metadata is the fact that the assembly contains a class named "MyClass" and that class contains a method named "DoSomething" with certain parameters, etc. So it's nothing mysterious - just "obvious" stuff mainly.

提交回复
热议问题