Given two strings like x=?hello? and y=?open?, remove any
character from string x which is also used in string y,
thus making the result x=?hll?.

Answer Posted / jethvamohit

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string str = "mohim";
string str1 = "mo";
remove(str, str1);
}
private static void remove(string str,string str1)
{
char[] abc;
abc = str.ToCharArray();
char[] bcd;
string str4 = "";
bcd = str1.ToCharArray();
for (int i = 0; i < bcd.Length; i++)
{
for (int j = 0; j < abc.Length; j++)
{
if (abc[j] != bcd[i])
{

str4 = str4 + abc[j];
}
}
abc = str4.ToCharArray();
str4 = "";
}
Console.Write(abc);
Console.ReadLine();

}
}
}

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does and I oop mean in text?

871


What is oops?what is its use in software engineering?

778


What is abstract class in oops?

797


What are benefits of oop?

896


What is meant by multiple inheritance?

961


What is multilevel inheritance?

972


What is a class oop?

774


What are the benefits of oop?

885


Why we use classes in oop?

794


Question In a class, there is a reference or pointer of an object of another class embedded, and the memory is either allocated or assigned to the new object created for this class. In the constructor, parameters are passed to initialize the data members and the embedded object reference to get inialized. What measures or design change should be advised for proper destruction and avioding memory leaks, getting pointers dangling for the embedded object memory allocation? Please suggest. Question Submitted By :: Sunil Kumar I also faced this Question!! Rank Answer Posted By Re: In a class, there is a reference or pointer of an object of another class embedded, and the memory is either allocated or assigned to the new object created for this class. In the constructor, parameters are passed to initialize the data members and the embedded object reference to get inialized. What measures or design change should be advised for proper destruction and avioding memory leaks, getting pointers dangling for the embedded object memory allocation? Please suggest. Answer # 1 use copy constructors 0 Shanthila There is something to be taken care in destructor, in copy constructor, suppose the memory is assigned to the embedded member object pointer with the parameter passed value, but if some other objects of different class also are pointing to this memory, then if some one deletes the object then this class member pointer object will become dangling, or if the object is not deleted properly then there will be memory leak. Please suggest the design change required to handle or avoid this situation

1921


Can enum be null?

784


What is the difference between a mixin and inheritance?

763


What does <> mean pseudocode?

859


What is polymorphism and why is it important?

794


Why do we use class?

833