Correct Code To Be Added For Overloaded Operator 8211 For The #314
Correct code to be added for overloaded operator – for the following C# code? </p> <pre><code class="language-csharp" line="1"> class csharp { int x, y, z; public csharp() { } public csharp(int a ,int b ,int c) { x = a; y = b; z = c; } Add correct set of code here public void display() { console.writeline(x + " " + y + " " + z); } class program { static void Main(String[] args) { csharp s1 = new csharp(5 ,6 ,8); csharp s3 = new csharp(); s3 = - s1; s3.display(); } } } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs108 CSharp. It can also be found in gs gs108 Object Oriented Concepts - Polymorphism - Quiz No.1.
Correct code to be added for overloaded operator – for the following C# code?
class csharp { int x, y, z; public csharp() { } public csharp(int a ,int b ,int c) { x = a; y = b; z = c; } Add correct set of code here public void display() { console.writeline(x + " " + y + " " + z); } class program { static void Main(String[] args) { csharp s1 = new csharp(5 ,6 ,8); csharp s3 = new csharp(); s3 = - s1; s3.display(); } } }
public static csharp operator -(csharp s1) { csharp t = new csharp(); t.x = s1.x; t.y = s1.y; t.z = -s1.z; return t; }
public static csharp operator -(csharp s1) { csharp t = new csharp(); t.x = s1.x; t.y = s1.y; t.z = s1.z; return t; }
public static csharp operator -(csharp s1) { csharp t = new csharp(); t.x = -s1.x; t.y = -s1.y; t.z = -s1.z; return t; }
None of the mentioned