Is there a specific term in C# to define the ‘method.method’ type of invocation?

wu sheng 20 Reputation points

In C#, we can use:




Please look at the following code, GetManager is a method, IsValid is also a method. Of course, GetManager will return an object. Ultimately, GetManager().IsValid(fileName) is actually an invocation of the ‘objectName.method’ type. But in form, GetManager().IsValid(fileName) is still a ‘method.method’ type of invocation.

My question is: Is there a specific term to define this ‘method.method’ syntax in C#? I want to search for this syntax knowledge based on the specific term.

public class LogAnalyzerUsingFactoryMethod
   public bool IsValidLogFileName(string fileName) 
         return GetManager().IsValid(fileName); 
   protected virtual IExtensionManager GetManager() 
         return new FileExtensionManager(); 

Microsoft Technologies based on the .NET software framework.
2,316 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
9,489 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce ( 48,876 Reputation points

    Method chaining is the name:

    api’s that use are often called fluent. It’s also used in the builder pattern.

    0 comments No comments

  2. Philip Stuyck 1 Reputation point

    Fluent api's are methods that are generally returning this. So you can continue to call methods on the object you started with like for instance is done in builders. Your api is far from fluent.

    What you are doing is just plain method call chaining. method1.method2 is confusing because that is not what you do. the result of method1 is an object, in your case a different one than where you began, and method2 is a method on the result object of method 1.

    I don 't even think there is a specific name for it. But if your so called 'chain' is too deep, they call it a train wreck and it is a design smell.

    0 comments No comments