Answer to Question #15908 in C# for leena

Question #15908
Define a class called MyString with these features:
1) An overloaded binary + operator that concatenates two MyString objects & create a third object.
2) An overloaded comparison == operator to comapre two strings.
3) An overloaded unary - (minus) operator that returns true if the string object is empty otherwise false.
1
Expert's answer
2012-10-08T09:03:10-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
public class MyString
{
& public String plus(String a, String b){
return a + b;
& }
& public bool compare(String a, String b)
& {
return a == b;
& }
& public bool minus(String a)
& {
return a == "";
& }
}
class Program
{
& static void Main(string[] args)
& {
String a;
a = "string";
String b;
b = "string";
MyString c = new MyString();
c.compare(a, b);
& }
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
08.10.12, 16:03

Dear visitor It's a complete code, it should work properly

leena
06.10.12, 11:46

Is this a complete coding ! Not running the program successfully.

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS