المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Inlined Code Question



C# Programming
07-13-2010, 03:41 AM
Below is sample code from one of my recent apps. I used this pattern a lot when designing searchable objects. I know that by appearances, there will be more than two method calls involved.
However, I've read that the C# compiler inlines short blocks of code.

Will the "Contained" method be inlined at compile time?


/// /// Returns a value indicating if the path contains the specified node type.
/// /// Specifies the node type. /// public bool Contains(BindingPathNodeType nodeType)
{
return IndexOf(nodeType) != -1;
}

/// /// Attempts to locate the first (zero-based) index position of the specified node type.
/// /// Specifies the node type. /// public int IndexOf(BindingPathNodeType nodeType)
{
int intCount = parsedPathNodes.Length;
for (int i = 0; i <span class="code-keyword">