Microsoft .NET اسئلة واجوبة المقابلات
Question: What is a reference parameter?Answer: Reference parameters reference the original object whereas value parameters make alocal copy and do not affect the original. Some example code is shown: using System; namespace Console1 { class Class1 { static void Main(string[] args) { TestRef tr1 = new TestRef(); TestRef tr2 = new TestRef(); tr1.TestValue = "Original value"; tr2.TestValue = "Original value"; int tv1 = 1; int tv2 = 1; TestRefVal(ref tv1, tv2, ref tr1, tr2); Console.WriteLine(tv1); Console.WriteLine(tv2); Console.WriteLine(tr1.TestValue); Console.WriteLine(tr2.TestValue); Console.ReadLine(); } static public void TestRefVal(ref int tv1Parm, int tv2Parm, ref TestRef tr1Parm, TestRef tr2Parm) { tv1Parm = 2; tv2Parm = 2; tr1Parm.TestValue = "New value"; tr2Parm.TestValue = "New value"; } } } class TestRef { public string TestValue; } The output for this is: 2 1 New value New value |
احفظ للمراجعة
احفظ هذا العنصر في الإشارات المرجعية، او حدده كصعب، او ضعه في مجموعة مراجعة.
سجل الدخول لحفظ الإشارات المرجعية والاسئلة الصعبة ومجموعات المراجعة.
هل هذا مفيد؟ نعم لا
الاكثر فائدة حسب تقييم المستخدمين:
- Name 10 C# keywords.
- What is public accessibility?
- .NET Stands for?
- What is private accessibility?
- What is protected accessibility?