Skip to main content

Posts

Showing posts from February, 2015

C# - Difference between String and Stringbuilder in C#, Asp.net

String String is immutable. Immutable means once we create string object we cannot modify. Any operation like insert, replace or append happened to change string simply it will discard the old value and it will create new instance in memory to hold the new value. Example string  str =  "hi" ; // create a new string instance instead of changing the old one str +=  "test" ; str +=  "help" ; String Builder String builder is mutable it means once we create string builder object we can perform any operation like insert, replace or append without creating new instance for every time. Example StringBuilder  sb =  new   StringBuilder ( "" ); sb.Append( "hi" ); sb.Append( "test " ); string  str = sb.ToString(); Differences String It’s an immutable Performance wise string is slow  because every time it will  create new instance In string we don’t have append keyword String belongs to 

OOPs Interview Question

All the programming languages supporting Object Oriented Programming will be supporting these three main concepts: Abstraction Encapsulation Inheritance Polymorphism Abstraction Abstraction is "To represent the essential feature without representing the background details."   Abstraction lets you focus on what the object does instead of how it does it.   Abstraction provides you a generalized view of your classes or objects by providing relevant information.   Abstraction is the process of hiding the working style of an object, and showing the information of an object in an understandable manner.   Real-world Example of Abstraction Suppose you have an object Mobile Phone.   Suppose you have 3 mobile phones as in the following:    Nokia 1400 (Features: Calling, SMS) Nokia 2700 (Features: Calling, SMS, FM Radio, MP3, Camera) Black Berry (Features:Calling, SMS, FM Radio, MP3, Camera, Video Recording, Reading E-mails)   Abstract information (necessary and common inf