Priti Kumari
What will be the output of this code?
By Priti Kumari in C# on Dec 09 2013
  • Murari Shrivastava
    Apr, 2014 24

    20 10

    • 2
  • Priti Kumari
    Dec, 2013 9

     struct sample
        {
            public int a;
        }
        class Program
        {
            static void Main(string[] args)
            {
                sample s = new sample();
                s.a = 10;
                Fun(s);
                Console.WriteLine(s.a);
                Console.ReadLine();
            }
            static void Fun(sample ss)
            {
                ss.a = 20;
                Console.WriteLine(ss.a);
            }
        }

    • 2
  • Ramendra kumar verma
    Jan, 2015 23

    10

    • 1
  • Pramod Lawate
    Dec, 2013 13

    just 10

    • 1
  • Subash
    Jul, 2016 13

    20 10

    • 0
  • Ram Nunna
    Aug, 2015 5

    20 10

    • 0
  • Rahul Prajapat
    Jun, 2015 1

    20 10

    • 0
  • Pankaj  Kumar Choudhary
    Jun, 2015 1

    20 10

    • 0
  • Manish Kaushal
    May, 2015 23

    20 10 coz struct is value type so it will assign different memory for both object.but if you will change struct with class then result will be 20 20 coz class is reference type and it will not assign different memory for different objects of a class.

    • 0
  • Rahul Rai
    Nov, 2014 13

    Wht r the correct answer priti ???i think 10 is right ans because in a main method do not create object of fun method

    • 0
  • Rahul Rai
    Nov, 2014 13

    10

    • 0
  • Najna Abdulla
    Sep, 2014 3

    what is the correct answer ??

    • 0
  • Tirthak Shah
    Jan, 2014 1

    10 Only

    • 0
  • Mahesh Alle
    Dec, 2013 16

    20 Next line 10

    • 0
  • Prabakaran Raja
    Dec, 2013 13

    20 10

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS