C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
Java
Learn iOS Programming
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
15
Reply
What will be the output of this code?
Priti Kumari
12y
2.7k
0
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
20 10
Murari Shrivastava
11y
2
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);
}
}
Priti Kumari
12y
2
10
Ramendra kumar verma
10y
1
just 10
Pramod Lawate
12y
1
20 10
Subash
9y
0
20 10
Ram Nunna
10y
0
20 10
Rahul Prajapat
10y
0
20 10
Pankaj Kumar Choudhary
10y
0
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.
Manish Kaushal
10y
0
Wht r the correct answer priti ???i think 10 is right ans because in a main method do not create object of fun method
Rahul Rai
11y
0
10
Rahul Rai
11y
0
what is the correct answer ??
Najna Abdulla
11y
0
10 Only
Tirthak Shah
11y
0
20 Next line 10
Mahesh Alle
12y
0
20 10
Prabakaran Raja
12y
0
Message