Asp.net programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this Asp.net and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Asp.net Website by URL, How to Play YouTube Videos in Asp.net by using Jquery , Jquery Change div background on mouseover in asp.net , JQuery UI Datepicker (Calendar) etc.

Tuesday, February 21, 2017

What does Mutable means?.IS STRING MUTABLE OR IMMUTABLE IN .NET?

 Mutable means:



Mutable means whose state can be changed after it is created. In simple terms to remind and understand the term you can relate it by word "Mutants". For ex- In X-Men, Jennifer Lawrence has the power to change itself from Mutant to Human being and back to mutant.


What does Immutable means?

Immutable: Immutable means whose state cannot be changed once it is created. For ex- A human being cannot change its state. He can wear a different type costume to look different but that doesn't mean his state has been changed.

Well, we are very much clear about the differences between these two terms.  
Now, put our focus on iterating whether strings are mutable or immutable?



Example :

Practical Implementation:
using System;
namespace AspnetSolutions
{    class StringImmutableNotMutable 
   {        public static void Main()    
    {          string rootStr = "Imaginationhunt.blogspot";


          // Operations(O)    

      string manipulateStr = rootStr.Replace('o', 'a');  // O1. Applying Replace()
          // Results(R)   

       Console.WriteLine("Original String = " + rootStr);  //R1. "rootStr" Before operation    

       Console.WriteLine("Using Replace()= " + manipulateStr); //R2. replacing performed     

     Console.WriteLine("Original String = " + rootStr);  //R3. ''rootStr" After operation          // Operations(O)


          string concatenateStr = rootStr + ".com";           // O2. Applying Concatenation



            
          string concatenateStr = rootStr + ".com";           // O2. Applying Concatenation                      // Results(R)     

     Console.WriteLine("After Concatenate = " + concatenateStr);//R4. concat performed 

         Console.WriteLine("Original String = " + rootStr);//R5. "rootStr" After concatenation   

     } 

   
}

}





Related Post : 



No comments:

Post a Comment