Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Reference Type parameter by Ref vs. Normal
//Microsoft (R) Visual C# Compiler version 3.4.0-beta4-19562-05 (ff930dec) //Copyright (C) Microsoft Corporation. All rights reserved. using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { MyType myInstance = new MyType() { MyInt = 5, MyDate = DateTime.MinValue, MyString = "One" }; //Your code goes here Console.WriteLine($"MyInt: {myInstance.MyInt}, MyDate: {myInstance.MyDate}, MyString: {myInstance.MyString}"); PassTypeHere(myInstance); Console.WriteLine($"MyInt: {myInstance.MyInt}, MyDate: {myInstance.MyDate}, MyString: {myInstance.MyString}"); PassTypeHereByRef(ref myInstance); Console.WriteLine($"MyInt: {myInstance.MyInt}, MyDate: {myInstance.MyDate}, MyString: {myInstance.MyString}"); } public static void PassTypeHere(MyType value) { value = new MyType() { MyInt = 10, MyDate = DateTime.MaxValue, MyString = "Two" }; Console.WriteLine($"MyInt: {value.MyInt}, MyDate: {value.MyDate}, MyString: {value.MyString}"); } public static void PassTypeHereByRef(ref MyType value) { value = new MyType() { MyInt = 10, MyDate = DateTime.MaxValue, MyString = "Two" }; Console.WriteLine($"MyInt: {value.MyInt}, MyDate: {value.MyDate}, MyString: {value.MyString}"); } public class MyType { public int MyInt { get; set; } public DateTime MyDate { get; set; } public string MyString { get; set; } } } }
run
|
edit
|
history
|
help
0
Hex_Base64
24 101 251 Primes
nguoi
Work Days
shell sort
Compress in C#
Vajdalinky
dsfsdfdf
First Class
c# specialization/overload