ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Microsoft Related  >>  C Sharp
 
 


 

 
 Visual Basic interview questions  Visual Basic Interview Questions
 C Sharp interview questions  C Sharp Interview Questions
 ASP.NET interview questions  ASP.NET Interview Questions
 VB.NET interview questions  VB.NET Interview Questions
 COM+ interview questions  COM+ Interview Questions
 ADO.NET interview questions  ADO.NET Interview Questions
 IIS interview questions  IIS Interview Questions
 MTS interview questions  MTS Interview Questions
 Crystal Reports interview questions  Crystal Reports Interview Questions
 BizTalk interview questions  BizTalk Interview Questions
 Dot Net interview questions  Dot Net Interview Questions
 Exchange Server interview questions  Exchange Server Interview Questions
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions
Question
how can i return string by vilating duplicates(inpyt like 
asdfsda but output should be 2a2d2sf and 2a,2d,2s,f)
 Question Submitted By :: Chandra
I also faced this Question!!     Rank Answer Posted By  
 
  Re: how can i return string by vilating duplicates(inpyt like asdfsda but output should be 2a2d2sf and 2a,2d,2s,f)
Answer
# 1
I suppose this question is intended to test the knowledge on
IEnumerator. The following piece of code may give the
required first part of the output...

string x = "asdfsdaaasasa";
            string output = "";
            int count = 0;
            IEnumerator ie = x.GetEnumerator();
            IEnumerator iee = x.GetEnumerator();
            while(ie.MoveNext())
            {
                while(iee.MoveNext())
                {
                    if ((char)ie.Current == (char)iee.Current)
                    {
                        count++;
                    }
                }
                iee.Reset();
                if (!output.Contains(ie.Current.ToString()))
                    output = output + count + ie.Current;
                count = 0;
            }
            Console.WriteLine(output);
 
Is This Answer Correct ?    1 Yes 0 No
Adityakiran
 
  Re: how can i return string by vilating duplicates(inpyt like asdfsda but output should be 2a2d2sf and 2a,2d,2s,f)
Answer
# 2
we can modify the previous answer to make it efficient...
check it..

string x = "asdfsdaaasasa";
            string output = "";
            int count = 0;
            IEnumerator ie = x.GetEnumerator();
            IEnumerator iee = x.GetEnumerator();
            while(ie.MoveNext())
            {
             if (!output.Contains(ie.Current.ToString()))
               {
                while(iee.MoveNext())
                {
                    if ((char)ie.Current == (char)iee.Current)
                    {
                        count++;
                    }
                }
                iee.Reset();                
                output = output + count + ie.Current;
                count = 0;
               }
            }
            Console.WriteLine(output);
 
Is This Answer Correct ?    0 Yes 0 No
Hari
 
 
 

 
 
 
Other C Sharp Interview Questions
 
  Question Asked @ Answers
 
how to retrive a TextBox value in to Sql database using C# windows form application coding  1
What is a system lock? Wipro1
directcast(123.34,integer) - should it throw an error? Why or why not? Wipro2
What?s the implicit name of the parameter that gets passed into the class? set method?  1
What?s the difference between an interface and abstract class? Patni2
ctype(123.34,integer) - should it throw an error? Why or why not? Wipro1
how to change a value of particular cell in a data grid  3
How can we give strong name to assembly? What is satellite assembly? SMNetserv1
What is indexers in C# Bodhtree1
What are the ways to deploy an assembly?  1
Can multiple catch blocks be executed? Visual-Soft4
How can we convert XML Data to DataBase Table in C#.Net? Wipro1
Can you prevent your class from being inherited and becoming a base class for some other classes?  3
coding for delegates? Tech-Mahindra3
What does assert() do?  1
how to store the value in textbox using delegates if we have two user control. the value will be called from one user control to another user control. Loading and unloading will be done through delegates.  1
How do you debug an ASP.NET Web application?  1
Can you override private virtual methods? Mind-Tree6
Diff b/w casting and boxing Wipro3
What is difference between value and reference types ? Accenture3
 
For more C Sharp Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com