Skip to main content

Posts

Showing posts with the label C# Interview Questions

Coding Challenge - ASP.NET Program : Count number of occurrences in a given string with additional criteria - StringComparison.InvariantCultureIgnoreCase

 Write a ASP.NET with C# program to achieve the following Given a sentence, count each word for number of occurrences (Main Criteria: No repetition) Additional Criteria  Case should be ignored Comma should not be counted An extra space more than single space should be ignored CountWord.aspx.cs < div >             < table >                 < tr >                     < td > Enter the string                     </ td >                     < td >                         < asp : TextBox ID ="txtInputString" Width ="500px" runat ="server">                         </ asp : TextBox >                     </ td >                     < td >                         < asp : Button ID ="btnShowResult" runat ="server" OnClick ="btnShowResult_Click" Text ="Click for result" />                     </ td >      

Coding Challenge - ASP.NET Program : Given a string S, shift each character to its immediate right character (note: preserve the cases)

Write a ASP.NET with C# program to achieve the following  "Given a string Str, shift each character to its immediate right character (Main Criteria: preserve the cases)" Sample input : HeLlo Sample output :  IfMmp ShiftNext.aspx < div >             < table >                 < tr >                     < td > Enter the string                     </ td >                     < td >                         < asp : TextBox ID ="txtInputString" runat ="server">                         </ asp : TextBox >                     </ td >                     < td >                         < asp : Button ID ="btnShowResult" runat ="server" OnClick ="btnShowResult_Click" Text ="Click for result" />                     </ td >                 </ tr >                 < tr >                     &l

What is the Real World use of Copy Constructor in C#

Copy constructor technique is not provided by .NET, but we can write one by our-self, This type of special constructor will take the paramater as object of its type, If you want create an object for a class with existing object values and only if you want to change some values the copy constructor will come for help Example: We have SalesRep class and we want to move all the reptative values in some set of object then we can re-use this,     class SalesRep     {         public int SalesRepID { get ; set ; }         public string SalesRepAddress { get ; set ; }         public string VisitingDoctor { get ; set ; }          public string DoctorAddress { get ; set ; }     } Writing a normal constructor which picks only the doctor details         public SalesRep( string pVisitingDoctor, string pDoctorAddress)         {             VisitingDoctor = pVisitingDoctor;             DoctorAddress = pDoctorAddress;         }