find a location for property in a new city

Wednesday, 7 December 2016

Reference object with ref keyword on a method. What's the point?

I wondered the other day what the point is in making a method parameter a ref when it is already a reference type. After playing around for a bit I came up with some concise code to illustrate the difference.

The difference is that, although you can modify the reference object that was passed in with both methods. Changing the reference entirely (i.e. pointing to a different object) only has an effect outside the scope of the method if the object was passed through with the ref keyword.

This code should explain better than English:

void Main()
{
 var t1 = new Thing();
 Test(t1);
 t1.Write(); // Chair
 
 var t2 = new Thing();
 Test(ref t2);
 t2.Write(); // Table
}

void Test(Thing t)
{
 t.Name = "Chair";
 t = new Thing { Name = "Table" };
}

void Test(ref Thing t)
{
 t.Name = "Chair";
 t = new Thing { Name = "Table" };
}

class Thing
{
 public string Name { get; set; }
 public void Write() => Console.WriteLine(Name);
}

Follow britishdev on Twitter

110 comments:

  1. I understand what you bring it very meaningful and useful, thanks


    mario | free mahjong  |   atari breakout

    ReplyDelete
  2. Informative post! I really amazed to see the great information that you have shared with us. I want to get more updates to increase my knowledge. Keep doing the great work up. trustable plumbers dallas

    ReplyDelete
  3. Your blog posts are more interesting and impressive. I think there are many people like and visit it regularly, including me.I actually appreciate your own position and I will be sure to come back here. five nights at freddy’s 4 | word cookies answers | hotmail sign in | hill climb racing 2

    ReplyDelete
  4. Thank you for this valuable information. The information you shared is very interesting. Brave Technologies is an leading erp software development company in chennai.
    enterprise resource planning chennai | web development company in chennai

    ReplyDelete
  5. This is one of the cult game now, a lot of people enjoy playing them . Also you can refer to the game :
    animal jam 2 | five nights at freddys 2 | hotmail login

    ReplyDelete
  6. This is a wonderful post. I enjoyed the information lot. I will bookmark this page. Thanks for sharing this information.
    starfall | barney | abcya

    ReplyDelete
  7. Thanks for sharing.for more information : click here

    ReplyDelete
  8. Your blog posts are more interesting and impressive. I think there are many people like and visit it regularly, including me.I actually appreciate your own position and I will be sure to come back here.
    potty-racers2.com

    ReplyDelete
  9. Here you can find some info on how to Compare and Contrast Essay and how to do it right

    ReplyDelete
  10. Thanks for the information I like to top article We provides list of verified get free quotes # Fooglepackers.com

    packers and movers pune
    packers and movers gurgaon
    packers and movers bangalore
    packers and movers noida

    ReplyDelete
  11. Thanks the information your best article provides list verified free quotes compare to save money & select the best # www.fooglepackers.com


    packers and movers delhi
    packers and movers mumbai
    packers and movers hyderabad
    packers and movers chennai

    ReplyDelete
  12. Interesting post! This is really helpful for me. I like it! Thanks for sharing!

    suchmaschinenmarketing lüdenscheid

    ReplyDelete
  13. We are top 5 mover and packer in Pune. Any problems are biggest definitely easier determine process by possible will flexion any workers are hard working with in your any time of the work him for her to the shifting relocation Foogle Packers Pune. List of packers movers in Pune with are process all over about tell me know as one by one services all over benefit from India is a very competition for the market in your competitor in all time location in Pune.

    http://www.fooglepackers.com/packersmovershyderabad.html

    http://www.fooglepackers.com/packersmoverspune.html

    http://www.fooglepackers.com/packersmoversmumbai.html

    ReplyDelete
  14. making a method parameter a ref when it is already a reference type
    ---------------------------------------------------------------------
    شركة تركيب طارد حمام بالرياض

    ReplyDelete
  15. Thanks for sharing this marvelous post. I m very pleased to read this article.Sign in pogo

    ReplyDelete
  16. Play Online Flash games What we call Free flash Games
    happy wheels is an extremely popular obstacle game developed by Fancy Force, Jim Bonacci and Jack Zankowski. This is a great game

    for you to experience.happy wheels is one of the best game all over internet In this web-based version, you will play Demo

    mode. There will be maps built by other players.Enjoy happy wheels game At the start of the game, you will have to take

    control of your character through dangerous paths, obstacles and deadly traps to reach the finish safely.Enjoy at the same time fireboy and watergirl game online as well

    ReplyDelete

  17. Before you plan to install antivirus software on your device, you are required to take
    few important steps to avoid software conflicts with the previously installed versions. please visit
    norton activation
    or directly visit
    norton.com/setup .
    you can find more topics there.We love to help you.

    ReplyDelete
  18. great informative post and A ref parameter is passed as a reference, not a value. This means you can assign the parameter in the called method and have it also be assigned at the calling site. Parameters. Difference. There is a difference between ref and out.coursework Writing Service

    ReplyDelete
  19. norton.com/setup - Online Help – Step by Step guide for Norton Setup, Download & complete installation online. We are providing independent support service if in case you face problem to activate or Setup Norton product.

    ReplyDelete
  20. office.com/setup - Let's Get Started with your Microsoft Office Setup by visiting www.office.com/setup and Enter 25-digit Activation Code to Setup Office Today. Feel free to contact us for any help.Office.com/setup

    ReplyDelete
  21. office.com/setup - Let's Get Started with your Microsoft Office Setup by visiting www.office.com/setup and Enter 25-digit Activation Code to Setup Office Today. Feel free to contact us for any help.

    ReplyDelete
  22. office.com/setup, office.com/verify, www office com setup, office.com/myaccount, Office Com Setup, office.com/productkeycard, Office Setup, setup.office.com, Office Com Set Up, office 2017 download, Office Setup Enter Product Key, office 2016 download, Office Setup Enter Key, office for mac download, Office Com Setup Enter Key

    ReplyDelete
  23. Thanks for writing such a great post. I really enjoyed reading that content.
    hooda games

    ReplyDelete
  24. Our technical experts will offer you the help to download, install and reinstall the McAfee product on your system. McAfee also provides the support to resolve the key related errors as well as the issues related to system performance.
    mcafee.com/activate

    Office.com/setup – Let’s Get Started with Office Setup Installation by simply following the steps discussed below. You may easily activate Office with the help of Office Com Setup link.
    Office.com/setup

    ReplyDelete
  25. Excellent Blog! I can't read articles online all the time, however I'm happy I did today. This is extremely elegantly composed and your focuses are very much communicated. 24 hour locksmith

    ReplyDelete
  26. Norton.com/setup – Setup your Norton subscription now with the help of this link. Let’s get started with your Norton Security today so just Activate Norton Subscription to enjoy the services. Website:- http://wwwnortoncomsetup.org/

    ReplyDelete
  27. AvriqPrinter RepairPrinter InstalltionWifi trouble shooting
    Software InstalltionI have just found this website while searching over the internet, you have posted valuable information which i like reading.

    ReplyDelete
  28. Take advantage of the opportunity with brandvaidya
    this is the best digital marketing in terms of SEO, Hq backlinks and brand Promotion along with Movies P.R And Celebrity Profiling.


    ReplyDelete
  29. McAfee.com/Activate - Enter 25 Digits Alpha-Numeric McAfee Activate Product Key at www.mcafee.com/activate. Get Started with McAfee Activation Today. To know more information regarding our services at https://mcafeecomactivate.support/

    ReplyDelete
  30. Get started office Setup with Product Key at www.office.com/setup. Sign in, Enter Product Key and install Office or call us toll-free +1-888-406-4114

    ReplyDelete
  31. Thank you so much for giving pieces of information. POGO online gaming is a perfect platform to make your dream come true. In case if you forget your Pogo account password or are you not able to recover pogo Account. visit here: Recover Pogo Account Password

    ReplyDelete

  32. Wireless range extenders
    are stand-alone equipment which sits between your wireless router and the location where you want better wireless coverage. To overcome The challenge with range-extenders is location click on the link above.

    ReplyDelete
  33. We have found an easy way to overcome router problem compare to other places on the internet.

    ReplyDelete
  34. This comment has been removed by the author.

    ReplyDelete
  35. Black Friday is an informal name for the day following Thanksgiving Day in the United States, the fourth Thursday of November, which has been regarded as the ...
    2017 date‎: ‎November 24 2019 date‎: ‎November 29
    2018 date‎: ‎November 23 2020 date‎: ‎November 27
    Cyber Monday 2018 Deals
    Black Friday 2018

    ReplyDelete
  36. Happy New Year Wishes Advance 2019 : We wish you a special Best happy new year 2019 with happy new year wishes advance 2019 that are specific for you ..
    Happy New Year 2019
    Happy New Year 2019 Status

    ReplyDelete
  37. At this point you'll find out what is important, it all gives a url to the appealing page:
    https://qualityseopackages.com/qspx-managed-whitelabel-seo-services/

    ReplyDelete
  38. I would like to say that this blog really convinced me to do it! Thanks, very good post.
    80 Niche Related links just 5$ on fiverr

    ReplyDelete
  39. You should have clearly define topics which you want to learn and start collecting study material according to that topics. you can feel stuck and could not find ways to approach your assignments, but, you can always seek for Programming Assignment Help.

    ReplyDelete
  40. Nice thoughts with great helping content. I have also been seeking such thoughfull content to learn and appy in the life. We have also created such type of content on our site. You can refer out site for more ideas.
    Happy New Year 2019 Wishes Messages Sms in Bengali
    Merry Christmas 2018 SMS, Wishes, Messages, Greetings in Bengali
    Merry Christmas 2018 Wishes Messages in Marathi,funny christmas text sms

    ReplyDelete
  41. می شود گفت که روش های درمان بواسیر در کمترین زمان کم نیستند مزایای درمان بواسیر با لیزر در مقایسه با سایر روش های درمان بواسیر زیاد است، این مزایا در آسانی این روش، انجام در وقت کم و استفاده نکردن از مواد بیهوشی سایر روشها، استفاده از لیزر برای برش خلاصه می شود.علت بواسیر چیست؟ بواسیر یا همان هموروئید در پایین ترین ناحیه راست روده و انسداد رگ ها ظاهر شده و باعث متورم شدن آن ناحیه می شود.راه های یافتن بهترین دکتر بواسیر, پزشک بواسیر, متخصص بواسیر یا هموروئید با رشد روزافزون فضای مجازی کاری سخت نیست. شما می توانید به بهترین مرکز درمان بواسیر مراجعه کنید.درمان شقاق با لیزر در حالت کلی عوارض جانبی ندارد ولی در مواردی نادر می تواند باعث توسعه فیستول، ​عفونت، بی‌ اختیاری کنترل مدفوع، خونریزی ​دو هفته ای باشد.

    ReplyDelete

  42. Nice thoughts with great helping content. I have also been seeking such thoughfull content to learn and appy in the life. We have also created such type of content on our site. You can refer out site for more ideas.

    pip camera new version 2019

    ReplyDelete
  43. I loved the article, keep updating interesting articles. I will be a regular reader… I am offering assignment help to students over the globe at a low price.
    "Assignment Help
    "
    "Assignment Helper
    "
    "Essay writing
    "
    "Essay writing service
    "
    "Dissertation help
    "
    "Thesis writing help
    "
    "Write My Essay
    "
    "Do My Essay
    "
    "Hire Cheap Essay Writer
    "
    "College Essay Help
    "

    ReplyDelete
  44. I found this one pretty fascinating and it should go into my collection. Very good work! I am Impressed. We appreciate that please keep going to write more content. We are the assignment helper, we provide services all over the globe. We are best in these services:-
    "Assignment Help
    "
    "Assignment Helper
    "
    "Essay writing
    "
    "Essay writing service
    "
    "Dissertation help
    "
    "Thesis writing help
    "
    "Write My Essay
    "
    "Computer Science Assignment Help
    "
    "Assignment Help Soth Africa
    "
    "Assignment Writing Service
    "

    ReplyDelete
  45. Thanks for sharing this information. I have shared this link with others keep posting such information. to provide best in class law assignment help online at very affordable prices.
    "Essay writing
    "
    "Essay Writer
    "
    "Article rewriter
    "
    "Essay writing service
    "
    "Essay writing help
    "
    "Write My Essay
    "
    "Write My Article
    "
    "Essay Helps
    "
    "Write my essay cheap
    "
    "Do my essay cheap
    "

    ReplyDelete
  46. Many of the people are depressed about the problems of essay writing. Well, don’t worry about that because we are providing this service at a very reasonable price.
    Digital Markrting Blog
    SEO Blog
    Social Media Blog
    Email Marketeting Blog
    Online marketing Blog

    ReplyDelete
  47. I loved the article, keep updating interesting articles. I will be a regular reader… I am offering assignment help to students over the globe at a low price.
    "Essay writing
    "
    "Essay Writer
    "
    "Article rewriter
    "
    "Essay writing service
    "
    "Essay writing help
    "
    "Write My Essay
    "
    "Write My Article
    "
    "Essay Helps
    "
    "Write my essay cheap
    "
    "Do my essay cheap
    "

    ReplyDelete
  48. I found this one pretty fascinating and it should go into my collection. Very good work! I am Impressed. We appreciate that please keep going to write more content. We are the assignment helper, we provide services all over the globe. We are best in these services:-
    "Assignment help NZ
    "
    "Assignment help NZ
    "
    "Assignment help UK
    "
    "Assignment help US
    "
    "Assignment help Australia
    "
    "Assignment help Canada
    "
    "Assignment helper
    "
    "Assignment help
    "
    "Writing Assignment Help
    "
    "Help For Assignment
    "
    "Write my assignment help
    "

    ReplyDelete

  49. Hi, thanks for sharing this informative article i love reading informative stuff your are doing great job keep up the good work. i am also running chatting website with top country that are below

    Live chat room
    live indian chat room
    Pakistani chat usa
    muslim chat rooms

    ReplyDelete
  50. Nice blog, I will keep visiting this blog very often.
    SEO BACKLINKS

    ReplyDelete
  51. Packers and Movers Bangalore as a Services providing company can make all the difference to your ###Home Relocation experience. Bangalore based Company which offers versatile solutions, Right team that easily reduce the stress associated with a ✔✔✔Household Shifting, ***Vehicle Transportation. we help things run smoothly and reduce breakages and offer you seamless, Affordable, Reliable Shifting Services, Compare Shifting Charges @
    Packers And Movers Bangalore

    ReplyDelete
  52. Packers and Movers Hyderabad Give Certified and Verified Service Providers, Cheap and Best ###Office Relocation Charges, ***Home Shifting, ✔ ✔ ✔ Goods Insurance worth Rs. 10,000, Assurance for Local and Domestic House Shifting. Safe and Reliable Household Shifting Services in Hyderabad with Reasonable Packers and Movers Price Quotation @
    Packers And Movers Hyderabad

    ReplyDelete
  53. Get Shifting/Relocation Quotation from ###Packers and Movers Delhi. Packers and Movers Delhi 100% Affordable and Reliable ***Household Shifting Services. Compare Transportation Charges and Save Time, Verified and Trusted Packers and Movers in Delhi, Cheap and Safe Local, Domestic House Shifting @
    Packers and Movers Delhi

    ReplyDelete
  54. Packers and Movers Chennai Give Safe and Reliable ***Household Shifting Services in Chennai with Reasonable ###Packers and Movers Price Quotation. We Provide Household Shifting, Office Relocation, ✔✔✔Local and Domestic Transportation Services, Affordable and Reliable Shifting Service Charges @
    Packers And Movers Chennai

    ReplyDelete
  55. Thanks for this informative content. It’s really good. Actually, I want to share some thoughts and reviews about an Australian assignment help company in Australia and the brand name is SAMPLE ASSIGNMENT. Here, I am working as an Academic Expert. To look at our online academic assistants who provide reference assignment including Accounting, Management, Finance, IT, Economics, Computer Science, Nursing, Marketing; all Academic subjects to University Students all over the Australia or even worldwide, Here is a big online assignment help providers who help students to get HD grades according to assessment guidelines and instructions. Those who are searching fo assignment help Melbourne, Perth, Brisbane, Adelaide etc. get a touch with Sample Assignment - the No.1 Assignment provider. Any student really wants to buy an assignment at the cheapest price goes to our branded website and has a look and opts our amazing and informative services, you can avail of our convenient online assignment help and samples available on our website for free. You can download it if you want. Are you ready to get 100 out of 100 in your university assessment? We assign the best writer according to the subject for your academic problems and provide support in assignment writing services. Our Customer Care Executives are available 24*7 hours to assist you in the best possible manner. Phone calls and emails are the best methods used by online assignment maker.

    ReplyDelete
  56. Local Packers and Movers Bangalore List, Get Best Price Quotes, Compare Movers and packers Charges, Top, Local Household Shifting Services
    Packers And Movers Bangalore

    ReplyDelete
  57. Get FREE account and technical support for your McAfee consumer products and services. Find solutions to top issues online. Live support via chat and phones.
    mcafee.com/activate
    mcafee activate
    mcafee my account

    ReplyDelete
  58. Packers and Movers in Delhi -Air wares Packers and Movers could be a metropolis primarily based Packers Movers Company providing reliable and cost-efficient Packers Movers services, Packers and Movers in metropolis and Packing Moving services all told over Republic of India. it's branches all told the most cities of Republic of India. Packers and Movers in metropolis worth the emotions of our customers and thence take that any care, whereas moving and packaging the merchandise of our customers.

    ReplyDelete

  59. check here latest update of Hollywood, Bollywood and tollywood, celebrities Newsvx
    Shahrukh khan upcoming movies
    We are the best event organisers in delhi ncr
    Event organisers in delhi ncr
    social media marketing company in delhi
    Most of the people want graphic design in india to grow there product and brand
    Graphic design in delhi
    Best event management company in delhi ncr
    Webslogin is the best web designing company in india
    best web designing company in India
    Best wedding planning company in delhi ncr
    We are the best web designers in delhi ncr
    web designers in delhi
    led wall rental in delhi ncr
    lights and sound rental in delhi ncr

    ReplyDelete
  60. Packers and Movers in Delhi -Air wares Packers and Movers could be a metropolis primarily based Packers Movers Company providing reliable and cost-efficient Packers Movers services, Packers and Movers in metropolis and Packing Moving services all told over Republic of India. it's branches all told the most cities of Republic of India. Packers and Movers in metropolis worth the emotions of our customers and thence take that any care, whereas moving and packaging the merchandise of our customers.

    ReplyDelete
  61. I needed to thank you for this Incredible read !! 360result.in I unquestionably adored each and every piece of it.

    ReplyDelete
  62. This is certainly additionally an exceedingly wonderful offer everyone truly qualified on the lookout with. It's always not likely everyday there is chances read a little something. extremely well written article as https://www.studyplans.in . I will be sure to and return to read more of your useful information. Thanks for the post. I’ll certainly comeback.

    ReplyDelete
  63. This is certainly additionally an exceedingly wonderful offer everyone truly qualified on the lookout with. It's always not likely everyday there is chances read a little something. extremely well written article as https://apsscresult2019.in. I will be sure to and return to read more of your useful information. Thanks for the post. I’ll certainly comeback.

    ReplyDelete
  64. Running into unexpected error on Canon Printer, then contact us at Canon Printer Support Phone Number 1-888-840-1555 and obtain rapid solutions with no extra time investment.


    Canon Printer Support Phone Number

    Canon Printer Support Number

    Canon Support Phone Number

    Canon Support Number

    Canon Printer Helpline Number

    Canon Phone Number

    Canon Helpline Number

    ReplyDelete
  65. Thanks for sharing nice information with us. i like your post and all you share with us is uptodate and quite informative, i would like to bookmark the page so i can come here again to read you, as you have done a wonderful job. I found your blog using msn. This is an extremely well written article as studyplans.in . I will be sure to bookmark it and return to read more of your useful information. Thanks for the post. I’ll certainly comeback.

    ReplyDelete
  66. This is certainly additionally an exceedingly wonderful offer everyone truly qualified on the lookout with. It's always not likely everyday there is chances read a little something. extremely well written article as apsscresult2019.in . I will be sure to and return to read more of your useful information. Thanks for the post. I’ll certainly comeback

    ReplyDelete
  67. This article is actually a nice one it helps new internet viewers, who are wishing in favor of blogging. And Another one from the same article as Click Here for more news.

    ReplyDelete
  68. This article is actually a nice one it helps new internet viewers, who are wishing in favor of blogging. And Another one from the same article as Click Here for more news.

    ReplyDelete
  69. Resolve any technical issue on a computer, smartphone or tablet that is interrupting Pogo games. Contact Pogo Customer Service Number 1-800-319-0494 for all types of consultation and support services.

    Pogo Game Help Number
    Pogo Support Phone Number
    Pogo Customer Service Number
    Club Pogo Support Number

    EA Support Phone Number

    XBOX Support Phone Number

    PlayStation Support Number


    ReplyDelete
  70. Running into unexpected error on Canon Printer, then contact us at Canon Customer Service Number 1-888-840-1555 and obtain rapid solutions with no extra time investment. Type us an email or dial our telephone number, we will respond to you ASAP!


    Canon Customer Service Number

    Canon Printer Technical Support Number
    Canon Customer Care Number

    Canon Printer Support Number
    Canon Pixma Printer Support Number
    Canon Scanner Support Number

    ReplyDelete
  71. Content-Sea

    thanks for sharing this posts. I would like to say you thanks

    ReplyDelete
  72. HP Customer Support "Customer Support Number 1-800-608-2315'is primarily focused on providing users a Toll-free customer support service.Find and contact HP Customer Support, download drivers, manuals and troubleshooting information for HP products, including pcs, laptops, desktops, printers, tablets, apps and services.

    Please feel free to call the HP support number or HP support phone number. The HP support number or HP support telephone number is available on the HP brand site. HP Support Center. If you are looking for an HP support center or an HP phone number, you will land on the correct page.


    Get in touch with HP Customer Service Number for HP Help

    hp customer support number

    hp Printer customer support number

    hp Cumputer support number

    ReplyDelete
  73. Nice information...you blog...
    We provide Dell Printer technical problem solution 24/7 to get help from our expert technical engineers. Call on: 1-844-881-6626 get assistance help from our reliable technician for Dell Printer Phone Number.

    Dell Printer Support Number
    Dell Printer Phone Number

    ReplyDelete
  74. I can set up my new idea from this post. It gives in depth information. Thanks for this valuable information for all,.. MP Architects LLP

    ReplyDelete
  75. Hi,
    Your article is very informative and has a lot of information. I really like your effort, keep posting.

    talkingtommodapk

    ReplyDelete
  76. Very Nice and Interesting Blog …. Keep Going..
    If you face any problem regarding AOL and if you aren't able to solve it on your own then don’t hesitate to contact AOL email support phone number +1-844-881-6626 to talk with the experienced experts and get help instantly from us. You can connect us through 24*7 support AOL Helpline number. Just call us on our AOL Support Phone Number +1-844-881-6626.

    Outlook Support phone number
    Outlook helpline Number
    Microsoft Outlook Support Number
    Gmail Support Phone Number
    Gmail Support Number
    Gmail Helpline Number

    ReplyDelete