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

  • Home
  • SEARCH
  • 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 123179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:14:44+00:00 2026-05-11T04:14:44+00:00

A few months ago I read about a technique so that if there parameters

  • 0

A few months ago I read about a technique so that if there parameters you passed in matched the local variables then you could use some short hand syntax to set them. To avoid this:

public string Method(p1, p2, p3) {     this.p1 = p1;     this.p2 = p2;     this.p3 = p3; } 

Any ideas?

  • 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. 2026-05-11T04:14:45+00:00Added an answer on May 11, 2026 at 4:14 am

    You may be thinking about the new object initializer syntax in C# 3.0. It looks like this:

    var foo = new Foo { Bar = 1, Fizz = 'hello' }; 

    So that’s giving us a new instance of Foo, with the ‘Bar’ property initialized to 1 and the ‘Fizz’ property to ‘hello’.

    The trick with this syntax is that if you leave out the ‘=’ and supply an identifier, it will assume that you’re assigning to a property of the same name. So, for example, if I already had a Foo instance, I could do this:

    var foo2 = new Foo { foo1.Bar, foo1.Fizz }; 

    This, then, is getting pretty close to your example. If your class has p1, p2 and p3 properties, and you have variables with the same name, you could write:

    var foo = new Foo { p1, p2, p3 }; 

    Note that this is for constructing instances only – not for passing parameters into methods as your example shows – so it may not be what you’re thinking of.

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

Sidebar

Related Questions

A few months ago I got an shocking email from Apple, telling that they
What happened to Dlinq? I heard a few years ago that it was abandoned.
I threw my portfolio together a few months ago and now I am trying
I am new to Android development since my EVO purchase a few months ago.
My environment consists of Visual Studio 2010 and Windows 7 a few months ago
I've tried to deal with this before, about 8 months ago, I didn't find
Few months ago I started some experiments with jQuery plugin. I found some tutorials
Over the last few months I've come across various chatter of external/private libraries not
I've been using nhibernate for a few months now and I am starting to
Selenium 2 has been in beta phase for last few months. I would like

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.