gs gs108 Miscellaneous Topics - Pointers Operation - Quiz No.2
gs gs108 CSharp Quiz
This quiz belongs to book/course code gs gs108 CSharp of gs organization. We have 110 quizzes available related to the book/course CSharp. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Miscellaneous Topics. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
class UnsafeCode { struct MyStruct { public int a; public int b; public int Sum() { return a * b; } } unsafe static void Main() { MyStruct o = new MyStruct(); MyStruct* p; p = &o; p->a = 10; p->b = 20; Console.WriteLine("Value is " + p->Sum()); Console.ReadLine(); } }
class UnsafeCode { struct MyStruct { public int a; public int b; public int Sum() { return a / b; } } unsafe static void Main() { MyStruct o = new MyStruct(); MyStruct* p; p = &o; p->a = 60; p->b = 15; int c = 30; Console.WriteLine("Value is : " + p->Sum()*c); Console.ReadLine(); } }
class UnsafeCode { unsafe static void Main() { int[] nums = new int[10]; fixed (int* p = &nums[0], p2 = nums) { if (p == p2) Console.WriteLine("p and p2 point to same address."); Console.ReadLine(); } } }
class UnsafeCode { static void Main() { int? count = null; int? result = null; int incr = 10; result = count + incr; if (result.HasValue) Console.WriteLine("result has this value: " + result.Value); else Console.WriteLine("result has no value"); Console.ReadLine(); } }
class UnsafeCode { static void Main() { int count = 100; int? result = null; int incr = 10; result = count + incr; if (result.HasValue) Console.WriteLine("result has this value: " + result.Value); else Console.WriteLine("result has no value"); Console.ReadLine(); } }
i. System.Nullable<int> count; ii. bool? done;
unsafe struct FixedBankRecord { public fixed byte Name[80]; public double Balance; public long ID; } class UnsafeCode { unsafe static void Main() { Console.WriteLine("Size of FixedBankRecord is " + sizeof(FixedBankRecord)); Console.ReadLine(); } }
class UnsafeCode { unsafe static void Main() { int* ptrs = stackalloc int[3]; ptrs[0] = 1; ptrs[1] = 2; ptrs[2] = 3; for (int i = 2; i >=0; i--) Console.WriteLine(ptrs[i]); Console.ReadLine(); } }