MetadataStringComparer Struct
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides string comparison helpers to query strings in metadata while avoiding allocation if possible.
public value class MetadataStringComparer
public struct MetadataStringComparer
public readonly struct MetadataStringComparer
type MetadataStringComparer = struct
Public Structure MetadataStringComparer
- Inheritance
Remarks
No allocation is performed unless both the handle argument and the value argument contain non-ASCII text.
Obtain instances using StringComparer. A default-initialized instance is useless and behaves as a null
reference.
The code is optimized so that there is no additional overhead in re-obtaining a comparer over assigning it to a local. That is to say that a construct like:
if (reader.StringComparer.Equals(typeDef.Namespace, "System") && reader.StringComparer.Equals(typeDef.Name, "Object")
{
/* found System.Object */
}
is no less efficient than:
var comparer = reader.StringComparer;
if (comparer.Equals(typeDef.Namespace, "System") && comparer.Equals(typeDef.Name, "Object")
{
/* found System.Object */
}
The choice between them is therefore one of style and not performance.
Methods
Applies to
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈