Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Store reference to a object
using System; namespace RexTester { public class ClassA<T> { T t; public T func(T num) { t = (T)(object)(2 * (double)(object)num);//t has to be assigned in this method (not in func2) ref T x = ref func2(); t = (T)(object)(3 * (double)(object)num);//t will be reassigned here, and I want this to be reflected in x return x;//I want x to be 9 not 6 } public ref T func2() { return ref t; } } public class Program { public static void Main(string[] args) { ClassA<double> a = new ClassA<double>(); Console.WriteLine(a.func(3.0)); Console.ReadLine(); } } }
run
|
edit
|
history
|
help
0
temp_with_pow
Creating async methods in C# prior to version 5.0
Math 10.94 test
working aes encryption/decryption
asxsadxsdf
0/1 Knapsack problem using Iterative Approach
Using Yield Return to mass copy a Class instance
john
Reflection custom test
Using Events/Delegates to Subscribe To A Service - Emails