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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

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.

@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
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
2 participants