Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add expression-bodied members examples with parameters #47035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 2, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 30, 2025

This PR addresses the feedback that the expression-bodied members documentation needed more examples showing parameter usage. Previously, only the constructor and indexer sections demonstrated expression-bodied members with parameters.

Changes Made

Methods Section

Added four new method examples to the Person class demonstrating various parameter patterns:

// String parameter usage
public string GetFullName(string title) => $"{title} {fname} {lname}";

// Integer parameter usage  
public int CalculateAge(int birthYear) => DateTime.Now.Year - birthYear;

// Parameter in conditional expression
public bool IsOlderThan(int age) => CalculateAge(1990) > age;

// Parameter transformation
public string FormatName(string format) => format.Replace("{first}", fname).Replace("{last}", lname);

Constructors Section

Added a new Point class with multiple constructor parameter examples:

// Constructor with multiple parameters using tuple assignment
public Point(double x, double y) => (X, Y) = (x, y);

// Constructor with single parameter
public Point(double coordinate) => (X, Y) = (coordinate, 0);

Documentation Updates

  • Updated the Methods section description to emphasize the new parameter examples
  • Updated the Constructors section description to highlight multiple parameter usage
  • Enhanced explanatory text to better guide readers through parameter patterns

Validation

  • ✅ All code examples build successfully
  • ✅ Examples run correctly and produce expected output
  • ✅ Markdown linting passes with no errors
  • ✅ Demonstrates practical, real-world parameter usage patterns

Before: Limited parameter examples (constructor only)
After: Comprehensive parameter examples across methods and constructors

Fixes #11790.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.


Internal previews

📄 File 🔗 Preview link
docs/csharp/programming-guide/statements-expressions-operators/expression-bodied-members.md docs/csharp/programming-guide/statements-expressions-operators/expression-bodied-members

@Copilot Copilot AI changed the title [WIP] Expression-bodied members section needs examples with parameters Add expression-bodied members examples with parameters Jun 30, 2025
@Copilot Copilot AI requested a review from BillWagner June 30, 2025 19:54
Copilot finished work on behalf of BillWagner June 30, 2025 19:54
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM. I'll mark it ready for final review.

@BillWagner BillWagner marked this pull request as ready for review July 1, 2025 16:17
@BillWagner BillWagner requested review from IEvangelist and a team as code owners July 1, 2025 16:17
@BillWagner
Copy link
Member

@IEvangelist Can you review this one?

@BillWagner BillWagner enabled auto-merge (squash) July 1, 2025 16:17
@BillWagner BillWagner merged commit 39b82a0 into main Jul 2, 2025
22 checks passed
@BillWagner BillWagner deleted the copilot/fix-11790 branch July 2, 2025 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expression-bodied members section needs examples with parameters
3 participants