Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 801199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:24:21+00:00 2026-05-14T23:24:21+00:00

If I have a method chain like the following: var abc = new ABC();

  • 0

If I have a method chain like the following:

        var abc = new ABC();
        abc.method1()
           .method2()
           .methodThrowsException()
           .method3()
           ;

assuming I’ve defined method1(), method2() and method3() as

    public ABC method1() {
        return this;
    }

and methodThrowsException() as

    public ABC method3() {
        throw new ArgumentException();
    }

When running the code, is it possible to know which specific line of code has thrown the Exception, or will it just consider all the method chaining as just one line? I’ve done a simple test and it seems it considers them all as just one line but Method Chaining says

Putting methods on separate lines also
makes debugging easier as error
messages and debugger control is
usually on a line by line basis.

Am I missing something, or does that just not apply to C#?

Thanks

Edit:
here is what i currently get:

alt text http://img163.imageshack.us/img163/4503/83077881.png

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:24:22+00:00Added an answer on May 14, 2026 at 11:24 pm

    If you look at the stack trace, which is displayed as part of the exception details, you should see the exact location of the exception, no matter how you format the code.

    I guess that formatting the code differently would be useful if the debugger allowed you to put a breakpoint on a specific line, but in C#, breakpoints are placed on individual expressions, so this won’t really help. You’d probably need to rewrite the code like this to allow placing breakpoints:

    var abc = new ABC(); 
    var abc1 = abc.method1();
    var abc2 = abc1.method2();
    // etc...
    

    The same applies to highlighting of the current expression (in your screenshot). However, the exact information about the exception are always available in the stack trace.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class like this class Foo attr_accessor :name end f = Foo.new
I'm considering the following: I have some data stream which I'd like to protect
I have found this example on StackOverflow: var people = new List<Person> { new
I have a piece of software written with fluent syntax. The method chain has
I have some classes that i'd like chain methods of to provide a fluent
I have a method which takes params object[] such as: void Foo(params object[] items)
I have class method that returns a list of employees that I can iterate
I have a method that where I want to redirect the user back to
I have a method in my Python code that returns a tuple - a
I have a method that can return either a single object or a collection

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.